From 1aa9ab510401dd2f1f4a9adcd48329b9f435e4e9 Mon Sep 17 00:00:00 2001 From: Ioannis Tsakpinis Date: Sun, 26 Sep 2010 23:43:24 +0000 Subject: [PATCH] Added support for OpenCL & CL/GL interop + minor improvements. [WIP] --- build.xml | 92 +- platform_build/build-definitions.xml | 63 +- platform_build/build-generator.xml | 113 +- platform_build/linux_ant/build.xml | 14 +- src/java/org/lwjgl/BufferChecks.java | 56 +- src/java/org/lwjgl/BufferUtils.java | 10 + src/java/org/lwjgl/LWJGLUtil.java | 50 +- src/java/org/lwjgl/PointerBuffer.java | 924 +++++++++++++ .../lwjgl/{opengl => }/PointerWrapper.java | 8 +- .../org/lwjgl/PointerWrapperAbstract.java | 75 ++ src/java/org/lwjgl/Sys.java | 29 +- src/java/org/lwjgl/opencl/APIUtil.java | 580 ++++++++ .../lwjgl/opencl/APPLEContextLoggingUtil.java | 77 ++ src/java/org/lwjgl/opencl/CL.java | 148 ++ .../lwjgl/opencl/CLBuildProgramCallback.java | 63 + src/java/org/lwjgl/opencl/CLCallback.java | 59 + src/java/org/lwjgl/opencl/CLChecks.java | 259 ++++ src/java/org/lwjgl/opencl/CLCommandQueue.java | 97 ++ src/java/org/lwjgl/opencl/CLContext.java | 135 ++ .../org/lwjgl/opencl/CLContextCallback.java | 78 ++ src/java/org/lwjgl/opencl/CLDevice.java | 191 +++ src/java/org/lwjgl/opencl/CLDeviceImpl.java | 104 ++ src/java/org/lwjgl/opencl/CLEvent.java | 86 ++ .../org/lwjgl/opencl/CLEventCallback.java | 61 + .../org/lwjgl/opencl/CLFunctionAddress.java | 47 + src/java/org/lwjgl/opencl/CLKernel.java | 113 ++ src/java/org/lwjgl/opencl/CLKernelImpl.java | 77 ++ src/java/org/lwjgl/opencl/CLMem.java | 66 + .../opencl/CLMemObjectDestructorCallback.java | 52 + src/java/org/lwjgl/opencl/CLNativeKernel.java | 59 + src/java/org/lwjgl/opencl/CLObject.java | 88 ++ src/java/org/lwjgl/opencl/CLObjectChild.java | 58 + .../org/lwjgl/opencl/CLObjectRegistry.java | 55 + .../lwjgl/opencl/CLObjectRegistryGlobal.java | 59 + src/java/org/lwjgl/opencl/CLPlatform.java | 104 ++ src/java/org/lwjgl/opencl/CLPlatformImpl.java | 121 ++ src/java/org/lwjgl/opencl/CLProgram.java | 94 ++ src/java/org/lwjgl/opencl/CLSampler.java | 56 + src/java/org/lwjgl/opencl/CallbackUtil.java | 200 +++ .../org/lwjgl/opencl/OpenCLException.java | 54 + src/java/org/lwjgl/opencl/Util.java | 76 ++ src/java/org/lwjgl/opencl/api/Filter.java | 51 + .../lwjgl/opengl/AMDDebugOutputCallback.java | 31 +- .../org/lwjgl/opengl/AMDDebugOutputUtil.java | 59 - .../opengl/{APIUtils.java => APIUtil.java} | 4 +- .../lwjgl/opengl/ARBDebugOutputCallback.java | 33 +- .../org/lwjgl/opengl/ARBDebugOutputUtil.java | 60 - src/java/org/lwjgl/opengl/AWTGLCanvas.java | 9 + .../org/lwjgl/opengl/AbstractDrawable.java | 8 + src/java/org/lwjgl/opengl/CallbackUtil.java | 157 +++ src/java/org/lwjgl/opengl/Context.java | 29 +- src/java/org/lwjgl/opengl/ContextAttribs.java | 23 + src/java/org/lwjgl/opengl/Drawable.java | 12 + src/java/org/lwjgl/opengl/GLSync.java | 14 +- .../opengl/LinuxContextImplementation.java | 4 + .../opengl/WindowsContextImplementation.java | 4 + .../org/lwjgl/test/opencl/HelloOpenCL.java | 185 +++ .../org/lwjgl/test/opencl/gl/DemoFractal.java | 675 ++++++++++ .../org/lwjgl/test/opencl/gl/Mandelbrot.cl | 55 + .../org/lwjgl/test/opengl/VersionTest.java | 3 + .../org/lwjgl/util/generator/Alternate.java | 3 + .../org/lwjgl/util/generator/AutoSize.java | 3 +- src/java/org/lwjgl/util/generator/Check.java | 2 +- src/java/org/lwjgl/util/generator/Code.java | 16 +- .../org/lwjgl/util/generator/Constant.java | 2 + .../{AutoResultSize.java => Extern.java} | 96 +- .../lwjgl/util/generator/GenerateAutos.java | 2 + .../generator/GeneratorProcessorFactory.java | 45 +- .../util/generator/GeneratorVisitor.java | 129 +- src/java/org/lwjgl/util/generator/Helper.java | 46 + .../org/lwjgl/util/generator/Imports.java | 46 + .../util/generator/JNITypeTranslator.java | 7 +- .../util/generator/JavaMethodsGenerator.java | 414 ++++-- .../util/generator/JavaTypeTranslator.java | 60 +- .../generator/NativeMethodStubsGenerator.java | 350 +++-- .../org/lwjgl/util/generator/NativeType.java | 3 +- .../util/generator/NativeTypeTranslator.java | 93 +- .../{StringList.java => PointerArray.java} | 2 +- .../{GLpointer.java => PointerWrapper.java} | 4 +- .../util/generator/PostfixTranslator.java | 3 +- .../org/lwjgl/util/generator/Private.java | 46 + .../generator/RegisterStubsGenerator.java | 38 +- src/java/org/lwjgl/util/generator/Reuse.java | 49 + .../util/generator/SignatureTranslator.java | 28 +- .../org/lwjgl/util/generator/TypeInfo.java | 8 +- .../org/lwjgl/util/generator/TypeMap.java | 22 +- .../util/generator/TypedefsGenerator.java | 23 +- src/java/org/lwjgl/util/generator/Utils.java | 73 +- .../generator/{ => openal}/ALTypeMap.java | 460 ++++--- .../generator/{ => openal}/ALboolean.java | 96 +- .../util/generator/{ => openal}/ALbyte.java | 96 +- .../util/generator/{ => openal}/ALdouble.java | 96 +- .../util/generator/{ => openal}/ALenum.java | 96 +- .../util/generator/{ => openal}/ALfloat.java | 96 +- .../util/generator/{ => openal}/ALint.java | 96 +- .../util/generator/{ => openal}/ALshort.java | 96 +- .../util/generator/{ => openal}/ALsizei.java | 96 +- .../util/generator/{ => openal}/ALubyte.java | 96 +- .../util/generator/{ => openal}/ALuint.java | 96 +- .../util/generator/{ => openal}/ALvoid.java | 96 +- .../opencl/CLCapabilitiesGenerator.java | 152 +++ .../generator/opencl/CLDeviceExtension.java | 41 + .../opencl/CLGeneratorProcessorFactory.java | 183 +++ .../opencl/CLPDCapabilitiesGenerator.java | 147 ++ .../generator/opencl/CLPlatformExtension.java | 41 + .../util/generator/opencl/CLTypeMap.java | 266 ++++ .../util/generator/opencl/cl_bitfield.java | 43 + .../lwjgl/util/generator/opencl/cl_bool.java | 43 + .../lwjgl/util/generator/opencl/cl_byte.java | 43 + .../lwjgl/util/generator/opencl/cl_char.java | 43 + .../util/generator/opencl/cl_double.java | 43 + .../lwjgl/util/generator/opencl/cl_float.java | 43 + .../lwjgl/util/generator/opencl/cl_int.java | 42 + .../lwjgl/util/generator/opencl/cl_long.java | 43 + .../lwjgl/util/generator/opencl/cl_short.java | 43 + .../lwjgl/util/generator/opencl/cl_uchar.java | 43 + .../lwjgl/util/generator/opencl/cl_uint.java | 42 + .../lwjgl/util/generator/opencl/cl_void.java | 45 + .../lwjgl/util/generator/opencl/size_t.java | 43 + .../GLCapabilitiesGenerator.java} | 645 ++++----- .../GLGeneratorProcessorFactory.java} | 378 +++--- ...LReferencesGeneratorProcessorFactory.java} | 413 +++--- .../generator/{ => opengl}/GLTypeMap.java | 623 +++++---- .../generator/{ => opengl}/GLbitfield.java | 96 +- .../generator/{ => opengl}/GLboolean.java | 96 +- .../util/generator/{ => opengl}/GLbyte.java | 96 +- .../util/generator/{ => opengl}/GLchar.java | 96 +- .../generator/{ => opengl}/GLcharARB.java | 96 +- .../util/generator/{ => opengl}/GLclampd.java | 96 +- .../util/generator/{ => opengl}/GLclampf.java | 96 +- .../util/generator/{ => opengl}/GLdouble.java | 96 +- .../util/generator/{ => opengl}/GLenum.java | 96 +- .../util/generator/{ => opengl}/GLfloat.java | 96 +- .../util/generator/{ => opengl}/GLhalf.java | 96 +- .../generator/{ => opengl}/GLhandleARB.java | 96 +- .../util/generator/{ => opengl}/GLint.java | 96 +- .../util/generator/{ => opengl}/GLint64.java | 4 +- .../generator/{ => opengl}/GLint64EXT.java | 4 +- .../util/generator/{ => opengl}/GLintptr.java | 96 +- .../generator/{ => opengl}/GLintptrARB.java | 96 +- .../util/generator/{ => opengl}/GLreturn.java | 4 +- .../util/generator/{ => opengl}/GLshort.java | 96 +- .../util/generator/{ => opengl}/GLsizei.java | 96 +- .../generator/{ => opengl}/GLsizeiptr.java | 96 +- .../generator/{ => opengl}/GLsizeiptrARB.java | 96 +- .../util/generator/{ => opengl}/GLtime.java | 4 +- .../util/generator/{ => opengl}/GLubyte.java | 96 +- .../util/generator/{ => opengl}/GLuint.java | 96 +- .../util/generator/{ => opengl}/GLuint64.java | 4 +- .../generator/{ => opengl}/GLuint64EXT.java | 4 +- .../util/generator/{ => opengl}/GLushort.java | 96 +- .../util/generator/{ => opengl}/GLvoid.java | 102 +- src/native/common/CL/cl.h | 998 ++++++++++++++ src/native/common/CL/cl_d3d10.h | 126 ++ src/native/common/CL/cl_ext.h | 213 +++ src/native/common/CL/cl_gl.h | 155 +++ src/native/common/CL/cl_gl_ext.h | 69 + src/native/common/CL/cl_platform.h | 1198 +++++++++++++++++ src/native/common/common_tools.c | 157 ++- src/native/common/common_tools.h | 32 +- src/native/common/extal.c | 36 +- src/native/common/extal.h | 32 +- src/native/common/extcl.c | 67 + src/native/common/extcl.h | 87 ++ src/native/common/extcl_types.h | 74 + src/native/common/extgl.h | 66 +- src/native/common/extgl_types.h | 55 + src/native/common/opencl.h | 56 + src/native/common/org_lwjgl_openal_AL.c | 32 +- src/native/common/org_lwjgl_opencl_CL.c | 56 + src/native/common/org_lwjgl_opencl_CL.h | 54 + .../common/org_lwjgl_opencl_CallbackUtil.c | 229 ++++ .../common/org_lwjgl_opencl_CallbackUtil.h | 94 ++ .../org_lwjgl_opengl_AMDDebugOutputCallback.c | 88 -- .../org_lwjgl_opengl_ARBDebugOutputCallback.c | 68 - .../common/org_lwjgl_opengl_CallbackUtil.c | 112 ++ .../common/org_lwjgl_opengl_CallbackUtil.h | 47 + src/native/linux/linux_al.c | 32 +- src/native/linux/linux_cl.c | 64 + ..._lwjgl_opengl_LinuxContextImplementation.c | 10 + src/native/macosx/macosx_al.c | 30 +- src/native/macosx/macosx_cl.c | 114 ++ ...wjgl_opengl_WindowsContextImplementation.c | 14 +- src/native/windows/windows_al.c | 32 +- src/native/windows/windows_cl.c | 73 + src/templates/org/lwjgl/openal/AL10.java | 3 +- src/templates/org/lwjgl/openal/AL11.java | 58 +- src/templates/org/lwjgl/openal/EFX10.java | 17 +- .../opencl/AMD_device_attribute_query.java | 45 + src/templates/org/lwjgl/opencl/AMD_fp64.java | 39 + .../org/lwjgl/opencl/AMD_media_ops.java | 39 + .../org/lwjgl/opencl/AMD_printf.java | 39 + .../opencl/APPLE_ContextLoggingFunctions.java | 64 + .../opencl/APPLE_SetMemObjectDestructor.java | 55 + .../org/lwjgl/opencl/APPLE_gl_sharing.java | 78 ++ src/templates/org/lwjgl/opencl/CL10.java | 1084 +++++++++++++++ src/templates/org/lwjgl/opencl/CL10GL.java | 138 ++ src/templates/org/lwjgl/opencl/CL11.java | 203 +++ .../org/lwjgl/opencl/EXT_device_fission.java | 144 ++ .../lwjgl/opencl/EXT_migrate_memobject.java | 77 ++ .../org/lwjgl/opencl/KHR_3d_image_writes.java | 39 + .../opencl/KHR_byte_addressable_store.java | 39 + src/templates/org/lwjgl/opencl/KHR_fp16.java | 39 + src/templates/org/lwjgl/opencl/KHR_fp64.java | 42 + .../org/lwjgl/opencl/KHR_gl_event.java | 56 + .../org/lwjgl/opencl/KHR_gl_sharing.java | 73 + .../opencl/KHR_global_int32_base_atomics.java | 39 + .../KHR_global_int32_extended_atomics.java | 39 + src/templates/org/lwjgl/opencl/KHR_icd.java | 57 + .../lwjgl/opencl/KHR_int64_base_atomics.java | 39 + .../opencl/KHR_int64_extended_atomics.java | 39 + .../opencl/KHR_local_int32_base_atomics.java | 39 + .../KHR_local_int32_extended_atomics.java | 39 + .../org/lwjgl/opengl/AMD_debug_output.java | 17 +- .../lwjgl/opengl/AMD_draw_buffers_blend.java | 4 +- .../org/lwjgl/opengl/AMD_name_gen_delete.java | 7 +- .../lwjgl/opengl/AMD_performance_monitor.java | 6 +- .../opengl/AMD_vertex_shader_tessellator.java | 2 +- .../org/lwjgl/opengl/APPLE_element_array.java | 1 + .../org/lwjgl/opengl/APPLE_fence.java | 7 +- .../opengl/APPLE_flush_buffer_range.java | 6 +- .../lwjgl/opengl/APPLE_object_purgeable.java | 4 + .../org/lwjgl/opengl/APPLE_texture_range.java | 3 + .../opengl/APPLE_vertex_array_object.java | 6 +- .../opengl/APPLE_vertex_array_range.java | 6 +- .../APPLE_vertex_program_evaluators.java | 4 +- .../lwjgl/opengl/ARB_ES2_compatibility.java | 6 + .../lwjgl/opengl/ARB_blend_func_extended.java | 7 + .../org/lwjgl/opengl/ARB_buffer_object.java | 8 +- .../org/lwjgl/opengl/ARB_cl_event.java | 54 + .../lwjgl/opengl/ARB_color_buffer_float.java | 2 +- .../org/lwjgl/opengl/ARB_copy_buffer.java | 8 +- .../org/lwjgl/opengl/ARB_debug_output.java | 19 +- .../org/lwjgl/opengl/ARB_draw_buffers.java | 5 +- .../lwjgl/opengl/ARB_draw_buffers_blend.java | 4 +- .../opengl/ARB_draw_elements_base_vertex.java | 4 + .../org/lwjgl/opengl/ARB_draw_indirect.java | 4 + .../org/lwjgl/opengl/ARB_draw_instanced.java | 1 + .../lwjgl/opengl/ARB_framebuffer_object.java | 32 +- .../lwjgl/opengl/ARB_geometry_shader4.java | 4 +- .../lwjgl/opengl/ARB_get_program_binary.java | 7 + .../org/lwjgl/opengl/ARB_gpu_shader_fp64.java | 20 + .../org/lwjgl/opengl/ARB_imaging.java | 3 + .../lwjgl/opengl/ARB_instanced_arrays.java | 2 +- .../lwjgl/opengl/ARB_map_buffer_range.java | 5 +- .../org/lwjgl/opengl/ARB_matrix_palette.java | 1 + .../org/lwjgl/opengl/ARB_multisample.java | 2 +- .../org/lwjgl/opengl/ARB_multitexture.java | 1 + .../org/lwjgl/opengl/ARB_occlusion_query.java | 7 +- .../lwjgl/opengl/ARB_point_parameters.java | 1 + .../org/lwjgl/opengl/ARB_program.java | 4 +- .../lwjgl/opengl/ARB_provoking_vertex.java | 4 +- .../org/lwjgl/opengl/ARB_robustness.java | 1 + .../org/lwjgl/opengl/ARB_sample_shading.java | 2 +- .../org/lwjgl/opengl/ARB_sampler_objects.java | 27 +- .../opengl/ARB_separate_shader_objects.java | 73 +- .../org/lwjgl/opengl/ARB_shader_objects.java | 12 +- .../lwjgl/opengl/ARB_shader_subroutine.java | 15 + .../opengl/ARB_shading_language_include.java | 8 +- src/templates/org/lwjgl/opengl/ARB_sync.java | 26 +- .../lwjgl/opengl/ARB_tessellation_shader.java | 3 + .../opengl/ARB_texture_buffer_object.java | 4 +- .../lwjgl/opengl/ARB_texture_compression.java | 3 + .../lwjgl/opengl/ARB_texture_multisample.java | 8 + .../org/lwjgl/opengl/ARB_timer_query.java | 7 + .../lwjgl/opengl/ARB_transform_feedback2.java | 16 +- .../lwjgl/opengl/ARB_transform_feedback3.java | 9 + .../opengl/ARB_uniform_buffer_object.java | 23 +- .../lwjgl/opengl/ARB_vertex_array_object.java | 12 +- .../lwjgl/opengl/ARB_vertex_attrib_64bit.java | 11 + .../org/lwjgl/opengl/ARB_vertex_blend.java | 1 + .../org/lwjgl/opengl/ARB_vertex_program.java | 21 + .../org/lwjgl/opengl/ARB_vertex_shader.java | 8 +- .../ARB_vertex_type_2_10_10_10_rev.java | 40 + .../org/lwjgl/opengl/ARB_viewport_array.java | 21 + .../org/lwjgl/opengl/ATI_draw_buffers.java | 5 +- .../org/lwjgl/opengl/ATI_element_array.java | 1 + .../org/lwjgl/opengl/ATI_envmap_bumpmap.java | 1 + .../org/lwjgl/opengl/ATI_fragment_shader.java | 2 + .../lwjgl/opengl/ATI_map_object_buffer.java | 4 +- .../org/lwjgl/opengl/ATI_pn_triangles.java | 2 +- .../lwjgl/opengl/ATI_separate_stencil.java | 3 +- .../lwjgl/opengl/ATI_vertex_array_object.java | 2 + .../ATI_vertex_attrib_array_object.java | 3 + .../org/lwjgl/opengl/ATI_vertex_streams.java | 1 + .../lwjgl/opengl/EXT_bindable_uniform.java | 4 +- .../org/lwjgl/opengl/EXT_blend_color.java | 2 +- .../opengl/EXT_blend_equation_separate.java | 2 +- .../lwjgl/opengl/EXT_blend_func_separate.java | 2 +- .../org/lwjgl/opengl/EXT_blend_minmax.java | 2 +- .../opengl/EXT_compiled_vertex_array.java | 2 +- .../lwjgl/opengl/EXT_depth_bounds_test.java | 2 +- .../lwjgl/opengl/EXT_direct_state_access.java | 52 +- .../org/lwjgl/opengl/EXT_draw_buffers2.java | 5 + .../org/lwjgl/opengl/EXT_draw_instanced.java | 1 + .../lwjgl/opengl/EXT_draw_range_elements.java | 1 + .../org/lwjgl/opengl/EXT_fog_coord.java | 4 + .../lwjgl/opengl/EXT_framebuffer_blit.java | 4 +- .../opengl/EXT_framebuffer_multisample.java | 4 +- .../lwjgl/opengl/EXT_framebuffer_object.java | 9 +- .../lwjgl/opengl/EXT_geometry_shader4.java | 4 +- .../opengl/EXT_gpu_program_parameters.java | 3 + .../org/lwjgl/opengl/EXT_gpu_shader4.java | 2 + .../lwjgl/opengl/EXT_multi_draw_arrays.java | 2 + .../lwjgl/opengl/EXT_paletted_texture.java | 1 + .../lwjgl/opengl/EXT_point_parameters.java | 1 + .../lwjgl/opengl/EXT_provoking_vertex.java | 2 +- .../org/lwjgl/opengl/EXT_secondary_color.java | 1 + .../opengl/EXT_separate_shader_objects.java | 4 + .../opengl/EXT_shader_image_load_store.java | 6 +- .../lwjgl/opengl/EXT_stencil_clear_tag.java | 3 +- .../lwjgl/opengl/EXT_stencil_two_side.java | 2 +- .../org/lwjgl/opengl/EXT_texture_array.java | 6 +- .../opengl/EXT_texture_buffer_object.java | 4 +- .../org/lwjgl/opengl/EXT_texture_integer.java | 8 +- .../org/lwjgl/opengl/EXT_timer_query.java | 2 + .../lwjgl/opengl/EXT_transform_feedback.java | 6 +- .../lwjgl/opengl/EXT_vertex_attrib_64bit.java | 2 + .../org/lwjgl/opengl/EXT_vertex_shader.java | 1 + .../lwjgl/opengl/EXT_vertex_weighting.java | 3 + src/templates/org/lwjgl/opengl/GL11.java | 4 +- src/templates/org/lwjgl/opengl/GL12.java | 1 + src/templates/org/lwjgl/opengl/GL13.java | 1 + src/templates/org/lwjgl/opengl/GL14.java | 1 + src/templates/org/lwjgl/opengl/GL15.java | 10 +- src/templates/org/lwjgl/opengl/GL20.java | 20 +- src/templates/org/lwjgl/opengl/GL21.java | 2 +- src/templates/org/lwjgl/opengl/GL30.java | 18 +- src/templates/org/lwjgl/opengl/GL31.java | 6 +- src/templates/org/lwjgl/opengl/GL32.java | 19 +- src/templates/org/lwjgl/opengl/GL33.java | 4 +- src/templates/org/lwjgl/opengl/GL40.java | 4 +- src/templates/org/lwjgl/opengl/GL41.java | 5 +- .../lwjgl/opengl/GREMEDY_string_marker.java | 2 + .../lwjgl/opengl/NV_conditional_render.java | 4 +- .../org/lwjgl/opengl/NV_copy_image.java | 6 +- .../org/lwjgl/opengl/NV_evaluators.java | 4 + .../lwjgl/opengl/NV_explicit_multisample.java | 8 +- src/templates/org/lwjgl/opengl/NV_fence.java | 7 +- .../org/lwjgl/opengl/NV_fragment_program.java | 3 + .../NV_framebuffer_multisample_coverage.java | 4 +- .../lwjgl/opengl/NV_geometry_program4.java | 8 +- .../org/lwjgl/opengl/NV_gpu_program4.java | 3 + .../org/lwjgl/opengl/NV_gpu_shader5.java | 40 +- .../org/lwjgl/opengl/NV_half_float.java | 4 + .../org/lwjgl/opengl/NV_occlusion_query.java | 7 +- .../opengl/NV_parameter_buffer_object.java | 3 + .../org/lwjgl/opengl/NV_pixel_data_range.java | 1 + .../org/lwjgl/opengl/NV_point_sprite.java | 1 + .../lwjgl/opengl/NV_primitive_restart.java | 1 + .../org/lwjgl/opengl/NV_program.java | 6 +- .../lwjgl/opengl/NV_register_combiners.java | 3 + .../lwjgl/opengl/NV_register_combiners2.java | 1 + .../lwjgl/opengl/NV_shader_buffer_load.java | 3 + .../lwjgl/opengl/NV_transform_feedback.java | 8 +- .../lwjgl/opengl/NV_transform_feedback2.java | 7 +- .../lwjgl/opengl/NV_vertex_array_range.java | 3 +- .../NV_vertex_attrib_integer_64bit.java | 1 + .../NV_vertex_buffer_unified_memory.java | 2 + .../org/lwjgl/opengl/NV_vertex_program.java | 1 + 360 files changed, 19079 insertions(+), 4193 deletions(-) create mode 100644 src/java/org/lwjgl/PointerBuffer.java rename src/java/org/lwjgl/{opengl => }/PointerWrapper.java (93%) create mode 100644 src/java/org/lwjgl/PointerWrapperAbstract.java create mode 100644 src/java/org/lwjgl/opencl/APIUtil.java create mode 100644 src/java/org/lwjgl/opencl/APPLEContextLoggingUtil.java create mode 100644 src/java/org/lwjgl/opencl/CL.java create mode 100644 src/java/org/lwjgl/opencl/CLBuildProgramCallback.java create mode 100644 src/java/org/lwjgl/opencl/CLCallback.java create mode 100644 src/java/org/lwjgl/opencl/CLChecks.java create mode 100644 src/java/org/lwjgl/opencl/CLCommandQueue.java create mode 100644 src/java/org/lwjgl/opencl/CLContext.java create mode 100644 src/java/org/lwjgl/opencl/CLContextCallback.java create mode 100644 src/java/org/lwjgl/opencl/CLDevice.java create mode 100644 src/java/org/lwjgl/opencl/CLDeviceImpl.java create mode 100644 src/java/org/lwjgl/opencl/CLEvent.java create mode 100644 src/java/org/lwjgl/opencl/CLEventCallback.java create mode 100644 src/java/org/lwjgl/opencl/CLFunctionAddress.java create mode 100644 src/java/org/lwjgl/opencl/CLKernel.java create mode 100644 src/java/org/lwjgl/opencl/CLKernelImpl.java create mode 100644 src/java/org/lwjgl/opencl/CLMem.java create mode 100644 src/java/org/lwjgl/opencl/CLMemObjectDestructorCallback.java create mode 100644 src/java/org/lwjgl/opencl/CLNativeKernel.java create mode 100644 src/java/org/lwjgl/opencl/CLObject.java create mode 100644 src/java/org/lwjgl/opencl/CLObjectChild.java create mode 100644 src/java/org/lwjgl/opencl/CLObjectRegistry.java create mode 100644 src/java/org/lwjgl/opencl/CLObjectRegistryGlobal.java create mode 100644 src/java/org/lwjgl/opencl/CLPlatform.java create mode 100644 src/java/org/lwjgl/opencl/CLPlatformImpl.java create mode 100644 src/java/org/lwjgl/opencl/CLProgram.java create mode 100644 src/java/org/lwjgl/opencl/CLSampler.java create mode 100644 src/java/org/lwjgl/opencl/CallbackUtil.java create mode 100644 src/java/org/lwjgl/opencl/OpenCLException.java create mode 100644 src/java/org/lwjgl/opencl/Util.java create mode 100644 src/java/org/lwjgl/opencl/api/Filter.java delete mode 100644 src/java/org/lwjgl/opengl/AMDDebugOutputUtil.java rename src/java/org/lwjgl/opengl/{APIUtils.java => APIUtil.java} (99%) delete mode 100644 src/java/org/lwjgl/opengl/ARBDebugOutputUtil.java create mode 100644 src/java/org/lwjgl/opengl/CallbackUtil.java create mode 100644 src/java/org/lwjgl/test/opencl/HelloOpenCL.java create mode 100644 src/java/org/lwjgl/test/opencl/gl/DemoFractal.java create mode 100644 src/java/org/lwjgl/test/opencl/gl/Mandelbrot.cl rename src/java/org/lwjgl/util/generator/{AutoResultSize.java => Extern.java} (87%) create mode 100644 src/java/org/lwjgl/util/generator/Helper.java create mode 100644 src/java/org/lwjgl/util/generator/Imports.java rename src/java/org/lwjgl/util/generator/{StringList.java => PointerArray.java} (96%) rename src/java/org/lwjgl/util/generator/{GLpointer.java => PointerWrapper.java} (87%) create mode 100644 src/java/org/lwjgl/util/generator/Private.java create mode 100644 src/java/org/lwjgl/util/generator/Reuse.java rename src/java/org/lwjgl/util/generator/{ => openal}/ALTypeMap.java (83%) rename src/java/org/lwjgl/util/generator/{ => openal}/ALboolean.java (89%) rename src/java/org/lwjgl/util/generator/{ => openal}/ALbyte.java (89%) rename src/java/org/lwjgl/util/generator/{ => openal}/ALdouble.java (89%) rename src/java/org/lwjgl/util/generator/{ => openal}/ALenum.java (89%) rename src/java/org/lwjgl/util/generator/{ => openal}/ALfloat.java (89%) rename src/java/org/lwjgl/util/generator/{ => openal}/ALint.java (89%) rename src/java/org/lwjgl/util/generator/{ => openal}/ALshort.java (89%) rename src/java/org/lwjgl/util/generator/{ => openal}/ALsizei.java (89%) rename src/java/org/lwjgl/util/generator/{ => openal}/ALubyte.java (89%) rename src/java/org/lwjgl/util/generator/{ => openal}/ALuint.java (89%) rename src/java/org/lwjgl/util/generator/{ => openal}/ALvoid.java (89%) create mode 100644 src/java/org/lwjgl/util/generator/opencl/CLCapabilitiesGenerator.java create mode 100644 src/java/org/lwjgl/util/generator/opencl/CLDeviceExtension.java create mode 100644 src/java/org/lwjgl/util/generator/opencl/CLGeneratorProcessorFactory.java create mode 100644 src/java/org/lwjgl/util/generator/opencl/CLPDCapabilitiesGenerator.java create mode 100644 src/java/org/lwjgl/util/generator/opencl/CLPlatformExtension.java create mode 100644 src/java/org/lwjgl/util/generator/opencl/CLTypeMap.java create mode 100644 src/java/org/lwjgl/util/generator/opencl/cl_bitfield.java create mode 100644 src/java/org/lwjgl/util/generator/opencl/cl_bool.java create mode 100644 src/java/org/lwjgl/util/generator/opencl/cl_byte.java create mode 100644 src/java/org/lwjgl/util/generator/opencl/cl_char.java create mode 100644 src/java/org/lwjgl/util/generator/opencl/cl_double.java create mode 100644 src/java/org/lwjgl/util/generator/opencl/cl_float.java create mode 100644 src/java/org/lwjgl/util/generator/opencl/cl_int.java create mode 100644 src/java/org/lwjgl/util/generator/opencl/cl_long.java create mode 100644 src/java/org/lwjgl/util/generator/opencl/cl_short.java create mode 100644 src/java/org/lwjgl/util/generator/opencl/cl_uchar.java create mode 100644 src/java/org/lwjgl/util/generator/opencl/cl_uint.java create mode 100644 src/java/org/lwjgl/util/generator/opencl/cl_void.java create mode 100644 src/java/org/lwjgl/util/generator/opencl/size_t.java rename src/java/org/lwjgl/util/generator/{ContextCapabilitiesGenerator.java => opengl/GLCapabilitiesGenerator.java} (91%) rename src/java/org/lwjgl/util/generator/{ContextGeneratorProcessorFactory.java => opengl/GLGeneratorProcessorFactory.java} (83%) rename src/java/org/lwjgl/util/generator/{ReferencesGeneratorProcessorFactory.java => opengl/GLReferencesGeneratorProcessorFactory.java} (93%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLTypeMap.java (86%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLbitfield.java (89%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLboolean.java (89%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLbyte.java (89%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLchar.java (89%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLcharARB.java (89%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLclampd.java (89%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLclampf.java (89%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLdouble.java (89%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLenum.java (89%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLfloat.java (89%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLhalf.java (89%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLhandleARB.java (88%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLint.java (89%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLint64.java (93%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLint64EXT.java (93%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLintptr.java (89%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLintptrARB.java (88%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLreturn.java (94%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLshort.java (89%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLsizei.java (89%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLsizeiptr.java (89%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLsizeiptrARB.java (88%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLtime.java (93%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLubyte.java (89%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLuint.java (89%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLuint64.java (93%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLuint64EXT.java (93%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLushort.java (89%) rename src/java/org/lwjgl/util/generator/{ => opengl}/GLvoid.java (86%) create mode 100644 src/native/common/CL/cl.h create mode 100644 src/native/common/CL/cl_d3d10.h create mode 100644 src/native/common/CL/cl_ext.h create mode 100644 src/native/common/CL/cl_gl.h create mode 100644 src/native/common/CL/cl_gl_ext.h create mode 100644 src/native/common/CL/cl_platform.h create mode 100644 src/native/common/extcl.c create mode 100644 src/native/common/extcl.h create mode 100644 src/native/common/extcl_types.h create mode 100644 src/native/common/extgl_types.h create mode 100644 src/native/common/opencl.h create mode 100644 src/native/common/org_lwjgl_opencl_CL.c create mode 100644 src/native/common/org_lwjgl_opencl_CL.h create mode 100644 src/native/common/org_lwjgl_opencl_CallbackUtil.c create mode 100644 src/native/common/org_lwjgl_opencl_CallbackUtil.h delete mode 100644 src/native/common/org_lwjgl_opengl_AMDDebugOutputCallback.c delete mode 100644 src/native/common/org_lwjgl_opengl_ARBDebugOutputCallback.c create mode 100644 src/native/common/org_lwjgl_opengl_CallbackUtil.c create mode 100644 src/native/common/org_lwjgl_opengl_CallbackUtil.h create mode 100644 src/native/linux/linux_cl.c create mode 100644 src/native/macosx/macosx_cl.c create mode 100644 src/native/windows/windows_cl.c create mode 100644 src/templates/org/lwjgl/opencl/AMD_device_attribute_query.java create mode 100644 src/templates/org/lwjgl/opencl/AMD_fp64.java create mode 100644 src/templates/org/lwjgl/opencl/AMD_media_ops.java create mode 100644 src/templates/org/lwjgl/opencl/AMD_printf.java create mode 100644 src/templates/org/lwjgl/opencl/APPLE_ContextLoggingFunctions.java create mode 100644 src/templates/org/lwjgl/opencl/APPLE_SetMemObjectDestructor.java create mode 100644 src/templates/org/lwjgl/opencl/APPLE_gl_sharing.java create mode 100644 src/templates/org/lwjgl/opencl/CL10.java create mode 100644 src/templates/org/lwjgl/opencl/CL10GL.java create mode 100644 src/templates/org/lwjgl/opencl/CL11.java create mode 100644 src/templates/org/lwjgl/opencl/EXT_device_fission.java create mode 100644 src/templates/org/lwjgl/opencl/EXT_migrate_memobject.java create mode 100644 src/templates/org/lwjgl/opencl/KHR_3d_image_writes.java create mode 100644 src/templates/org/lwjgl/opencl/KHR_byte_addressable_store.java create mode 100644 src/templates/org/lwjgl/opencl/KHR_fp16.java create mode 100644 src/templates/org/lwjgl/opencl/KHR_fp64.java create mode 100644 src/templates/org/lwjgl/opencl/KHR_gl_event.java create mode 100644 src/templates/org/lwjgl/opencl/KHR_gl_sharing.java create mode 100644 src/templates/org/lwjgl/opencl/KHR_global_int32_base_atomics.java create mode 100644 src/templates/org/lwjgl/opencl/KHR_global_int32_extended_atomics.java create mode 100644 src/templates/org/lwjgl/opencl/KHR_icd.java create mode 100644 src/templates/org/lwjgl/opencl/KHR_int64_base_atomics.java create mode 100644 src/templates/org/lwjgl/opencl/KHR_int64_extended_atomics.java create mode 100644 src/templates/org/lwjgl/opencl/KHR_local_int32_base_atomics.java create mode 100644 src/templates/org/lwjgl/opencl/KHR_local_int32_extended_atomics.java create mode 100644 src/templates/org/lwjgl/opengl/ARB_cl_event.java diff --git a/build.xml b/build.xml index c04b7581..c4dd46d7 100644 --- a/build.xml +++ b/build.xml @@ -32,19 +32,19 @@ - + - + - + - Build aborted by user. - + @@ -72,19 +72,19 @@ - + - + - + @@ -105,7 +105,7 @@ - + @@ -116,7 +116,7 @@ - + @@ -126,7 +126,7 @@ - + @@ -151,7 +151,7 @@ - + @@ -175,20 +175,20 @@ - - + + - + - + - + @@ -196,14 +196,14 @@ - + - - + + @@ -251,17 +251,18 @@ - - + + + - + - + @@ -276,7 +277,7 @@ - + @@ -297,7 +298,7 @@ - + @@ -307,14 +308,14 @@ lwjgl.java.windows.version = ${lwjgl.java.windows.version} - lwjgl.native.windows.version = ${lwjgl.native.windows.version} + lwjgl.native.windows.version = ${lwjgl.native.windows.version} lwjgl.java.linux.version = ${lwjgl.java.linux.version} - lwjgl.native.linux.version = ${lwjgl.native.linux.version} + lwjgl.native.linux.version = ${lwjgl.native.linux.version} lwjgl.java.macosx.version = ${lwjgl.java.macosx.version} - lwjgl.native.macosx.version = ${lwjgl.native.macosx.version} + lwjgl.native.macosx.version = ${lwjgl.native.macosx.version} - + @@ -325,7 +326,7 @@ - + @@ -333,27 +334,28 @@ - + - + - + + - - - - + + + + @@ -374,7 +376,7 @@ - + @@ -410,7 +412,7 @@ - + @@ -430,7 +432,7 @@ - + @@ -450,14 +452,14 @@ - + - + @@ -487,8 +489,8 @@ - - + + diff --git a/platform_build/build-definitions.xml b/platform_build/build-definitions.xml index fb3ae923..2ead6e94 100644 --- a/platform_build/build-definitions.xml +++ b/platform_build/build-definitions.xml @@ -2,19 +2,22 @@ - - - - - - - - - - + + + + + + + + + + + + + @@ -39,18 +42,16 @@ - + - - - - - - - - + + + + + @@ -66,7 +67,7 @@ - + @@ -95,15 +96,15 @@ - + - + - + @@ -111,13 +112,13 @@ - + - + - + @@ -132,7 +133,7 @@ - + @@ -143,15 +144,15 @@ - - + + - - + + diff --git a/platform_build/build-generator.xml b/platform_build/build-generator.xml index da8b16a2..1f2e1fdd 100644 --- a/platform_build/build-generator.xml +++ b/platform_build/build-generator.xml @@ -11,21 +11,38 @@ + + + - + + + + - + + + + + + + + + + + + - + - + @@ -39,7 +56,7 @@ - + @@ -56,7 +73,7 @@ - + @@ -75,7 +92,7 @@ - + @@ -94,17 +111,17 @@ - + - + - + @@ -113,12 +130,12 @@ - + - + @@ -128,12 +145,12 @@ - + - + @@ -143,4 +160,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform_build/linux_ant/build.xml b/platform_build/linux_ant/build.xml index 7e45c525..0058f056 100644 --- a/platform_build/linux_ant/build.xml +++ b/platform_build/linux_ant/build.xml @@ -16,7 +16,7 @@ - + @@ -27,10 +27,10 @@ - + - + @@ -50,7 +50,7 @@ - + @@ -58,11 +58,11 @@ - + - + @@ -89,7 +89,7 @@ - + diff --git a/src/java/org/lwjgl/BufferChecks.java b/src/java/org/lwjgl/BufferChecks.java index 9c21fda8..27b35904 100644 --- a/src/java/org/lwjgl/BufferChecks.java +++ b/src/java/org/lwjgl/BufferChecks.java @@ -87,13 +87,27 @@ public class BufferChecks { } } - /** Helper methods to ensure an IntBuffer is null-terminated */ + /** Helper method to ensure an IntBuffer is null-terminated */ public static void checkNullTerminated(IntBuffer buf) { if ( buf.get(buf.limit() - 1) != 0 ) { throw new IllegalArgumentException("Missing null termination"); } } + /** Helper method to ensure a LongBuffer is null-terminated */ + public static void checkNullTerminated(LongBuffer buf) { + if ( buf.get(buf.limit() - 1) != 0 ) { + throw new IllegalArgumentException("Missing null termination"); + } + } + + /** Helper method to ensure a PointerBuffer is null-terminated */ + public static void checkNullTerminated(PointerBuffer buf) { + if ( buf.get(buf.limit() - 1) != 0 ) { + throw new IllegalArgumentException("Missing null termination"); + } + } + public static void checkNotNull(Object o) { if ( LWJGLUtil.CHECKS && o == null) throw new IllegalArgumentException("Null argument"); @@ -138,6 +152,15 @@ public class BufferChecks { } } + public static void checkDirect(PointerBuffer buf) { + // NO-OP, PointerBuffer is always direct. + } + + public static void checkArray(Object[] array) { + if ( LWJGLUtil.CHECKS && array == null ) + throw new IllegalArgumentException("Invalid array"); + } + /** * This is a separate call to help inline checkBufferSize. */ @@ -145,6 +168,18 @@ public class BufferChecks { throw new IllegalArgumentException("Number of remaining buffer elements is " + buf.remaining() + ", must be at least " + size); } + private static void throwBufferSizeException(PointerBuffer buf, int size) { + throw new IllegalArgumentException("Number of remaining pointer buffer elements is " + buf.remaining() + ", must be at least " + size); + } + + private static void throwArraySizeException(Object[] array, int size) { + throw new IllegalArgumentException("Number of array elements is " + array.length + ", must be at least " + size); + } + + private static void throwArraySizeException(long[] array, int size) { + throw new IllegalArgumentException("Number of array elements is " + array.length + ", must be at least " + size); + } + /** * Helper method to ensure a buffer is big enough to receive data from a * glGet* operation. @@ -202,4 +237,21 @@ public class BufferChecks { checkDirect(buf); } } -} + + public static void checkBuffer(PointerBuffer buf, int size) { + if ( LWJGLUtil.CHECKS && buf.remaining() < size ) { + throwBufferSizeException(buf, size); + } + } + + public static void checkArray(Object[] array, int size) { + if ( LWJGLUtil.CHECKS && array.length < size ) + throwArraySizeException(array, size); + } + + public static void checkArray(long[] array, int size) { + if ( LWJGLUtil.CHECKS && array.length < size ) + throwArraySizeException(array, size); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/BufferUtils.java b/src/java/org/lwjgl/BufferUtils.java index 13c8275b..d798168e 100644 --- a/src/java/org/lwjgl/BufferUtils.java +++ b/src/java/org/lwjgl/BufferUtils.java @@ -120,6 +120,16 @@ public final class BufferUtils { return createByteBuffer(size << 3).asDoubleBuffer(); } + /** + * Construct a PointerBuffer with the specified number + * of elements. + * @param size The size, in memory addresses + * @return a PointerBuffer + */ + public static PointerBuffer createPointerBuffer(int size) { + return PointerBuffer.allocateDirect(size); + } + /** * @return n, where buffer_element_size=2^n. */ diff --git a/src/java/org/lwjgl/LWJGLUtil.java b/src/java/org/lwjgl/LWJGLUtil.java index 3d04447a..abbf0d6f 100644 --- a/src/java/org/lwjgl/LWJGLUtil.java +++ b/src/java/org/lwjgl/LWJGLUtil.java @@ -59,9 +59,9 @@ public class LWJGLUtil { public static final String PLATFORM_LINUX_NAME = "linux"; public static final String PLATFORM_MACOSX_NAME = "macosx"; public static final String PLATFORM_WINDOWS_NAME = "windows"; - + /** LWJGL Logo - 16 by 16 pixels */ - public static final ByteBuffer LWJGLIcon16x16 = BufferUtils.createByteBuffer(16 * 16 * 4).put(new byte[] { + public static final ByteBuffer LWJGLIcon16x16 = BufferUtils.createByteBuffer(16 * 16 * 4).put(new byte[] { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, -62, -41, -24, -1, 116, -92, -53, -1, 80, -117, -67, -1, 84, -114, -65, -1, -122, -81, -46, -1, -25, -17, -10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -106,7 +106,7 @@ public class LWJGLUtil { }); /** LWJGL Logo - 32 by 32 pixels */ - public static final ByteBuffer LWJGLIcon32x32 = BufferUtils.createByteBuffer(32 * 32 * 4).put(new byte[] { + public static final ByteBuffer LWJGLIcon32x32 = BufferUtils.createByteBuffer(32 * 32 * 4).put(new byte[] { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -6, -4, -3, -1, -53, -35, @@ -269,11 +269,23 @@ public class LWJGLUtil { public static final boolean CHECKS = !getPrivilegedBoolean("org.lwjgl.util.NoChecks"); + private static final int PLATFORM; + static { LWJGLIcon16x16.flip(); LWJGLIcon32x32.flip(); + + final String osName = getPrivilegedProperty("os.name"); + if ( osName.startsWith("Windows") ) + PLATFORM = PLATFORM_WINDOWS; + else if ( osName.startsWith("Linux") || osName.startsWith("FreeBSD") || osName.startsWith("SunOS") ) + PLATFORM = PLATFORM_LINUX; + else if ( osName.startsWith("Mac OS X") ) + PLATFORM = PLATFORM_MACOSX; + else + throw new LinkageError("Unknown platform: " + osName); } - + /** * @see #PLATFORM_WINDOWS * @see #PLATFORM_LINUX @@ -281,19 +293,9 @@ public class LWJGLUtil { * @return the current platform type */ public static int getPlatform() { - String osName = getPrivilegedProperty("os.name"); - - if (osName.startsWith("Windows")) { - return PLATFORM_WINDOWS; - } else if (osName.startsWith("Linux") || osName.startsWith("FreeBSD") || osName.startsWith("SunOS")) { - return PLATFORM_LINUX; - } else if (osName.startsWith("Mac OS X")) { - return PLATFORM_MACOSX; - } else { - throw new LinkageError("Unknown platform: " + osName); - } + return PLATFORM; } - + /** * @see #PLATFORM_WINDOWS_NAME @@ -312,7 +314,7 @@ public class LWJGLUtil { default: return "unknown"; } - } + } /** * Locates the paths required by a library. @@ -357,7 +359,7 @@ public class LWJGLUtil { String alternative_path = getPrivilegedProperty("org.lwjgl.librarypath"); if (alternative_path != null) { possible_paths.add(alternative_path + File.separator + platform_lib_name); - } + } // Add all possible paths from java.library.path String java_library_path = getPrivilegedProperty("java.library.path"); @@ -449,16 +451,16 @@ public class LWJGLUtil { */ private static boolean getPrivilegedBoolean(final String property_name) { Boolean value = (Boolean)AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + public Object run() { return new Boolean(Boolean.getBoolean(property_name)); } }); return value.booleanValue(); - } - + } + /** * Prints the given message to System.err if DEBUG is true. - * + * * @param msg Message to print */ public static void log(String msg) { @@ -466,7 +468,7 @@ public class LWJGLUtil { System.err.println(msg); } } - + /** * Method to determine if the current system is running a version of * Mac OS X better than the given version. This is only useful for Mac OS X @@ -489,5 +491,5 @@ public class LWJGLUtil { } return major > major_required || (major == major_required && minor >= minor_required); } - + } diff --git a/src/java/org/lwjgl/PointerBuffer.java b/src/java/org/lwjgl/PointerBuffer.java new file mode 100644 index 00000000..b541d86f --- /dev/null +++ b/src/java/org/lwjgl/PointerBuffer.java @@ -0,0 +1,924 @@ +/* + * 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; + +import java.lang.reflect.Method; +import java.nio.*; + +/** + * This class is a container for architecture independent pointer data. + * The interface mirrors the NIO LongBuffer API for convenience. + * + * @author Spasi + */ +public class PointerBuffer implements Comparable { + + private static final boolean is64Bit; + + static { + // Use reflection so that we can compile this class for the Generator. + boolean is64 = false; + try { + Method m = Class.forName("org.lwjgl.Sys").getDeclaredMethod("is64Bit", (Class[])null); + is64 = ((Boolean)m.invoke(null, (Object[])null)).booleanValue(); + } catch (Throwable t) { + // ignore + } finally { + is64Bit = is64; + } + } + + protected final ByteBuffer pointers; + + protected final Buffer view; + protected final IntBuffer view32; + protected final LongBuffer view64; + + public PointerBuffer(final int capacity) { + this(BufferUtils.createByteBuffer(capacity * getPointerSize())); + } + + public PointerBuffer(final ByteBuffer source) { + if ( !source.isDirect() ) + throw new IllegalArgumentException("ByteBuffer is not direct"); + + pointers = source.slice().order(source.order()); + + if ( is64Bit ) { + view32 = null; + view = view64 = pointers.asLongBuffer(); + } else { + view = view32 = pointers.asIntBuffer(); + view64 = null; + } + } + + /** + * Returns the ByteBuffer that backs this PointerBuffer. + * + * @return the pointer ByteBuffer + */ + public ByteBuffer getBuffer() { + return pointers; + } + + /** + * Returns the pointer size in bytes, based on the underlying architecture. + * + * @return The pointer size in bytes + */ + public static int getPointerSize() { + return is64Bit ? 8 : 4; + } + + /** + * Returns this buffer's capacity.

+ * + * @return The capacity of this buffer + */ + public final int capacity() { + return view.capacity(); + } + + /** + * Returns this buffer's position.

+ * + * @return The position of this buffer + */ + public final int position() { + return view.position(); + } + + /** + * Returns this buffer's position, in bytes.

+ * + * @return The position of this buffer in bytes. + */ + public final int positionByte() { + return position() * getPointerSize(); + } + + /** + * Sets this buffer's position. If the mark is defined and larger than the + * new position then it is discarded.

+ * + * @param newPosition The new position value; must be non-negative + * and no larger than the current limit + * + * @return This buffer + * + * @throws IllegalArgumentException If the preconditions on newPosition do not hold + */ + public final PointerBuffer position(int newPosition) { + view.position(newPosition); + return this; + } + + /** + * Returns this buffer's limit.

+ * + * @return The limit of this buffer + */ + public final int limit() { + return view.limit(); + } + + /** + * Sets this buffer's limit. If the position is larger than the new limit + * then it is set to the new limit. If the mark is defined and larger than + * the new limit then it is discarded.

+ * + * @param newLimit The new limit value; must be non-negative + * and no larger than this buffer's capacity + * + * @return This buffer + * + * @throws IllegalArgumentException If the preconditions on newLimit do not hold + */ + public final PointerBuffer limit(int newLimit) { + view.limit(newLimit); + return this; + } + + /** + * Sets this buffer's mark at its position.

+ * + * @return This buffer + */ + public final PointerBuffer mark() { + view.mark(); + return this; + } + + /** + * Resets this buffer's position to the previously-marked position. + *

+ *

Invoking this method neither changes nor discards the mark's + * value.

+ * + * @return This buffer + * + * @throws java.nio.InvalidMarkException If the mark has not been set + */ + public final PointerBuffer reset() { + view.reset(); + return this; + } + + /** + * Clears this buffer. The position is set to zero, the limit is set to + * the capacity, and the mark is discarded. + *

+ *

Invoke this method before using a sequence of channel-read or + * put operations to fill this buffer. For example: + *

+ *

+	 * buf.clear();     // Prepare buffer for reading
+	 * in.read(buf);    // Read data
+ *

+ *

This method does not actually erase the data in the buffer, but it + * is named as if it did because it will most often be used in situations + * in which that might as well be the case.

+ * + * @return This buffer + */ + public final PointerBuffer clear() { + view.clear(); + return this; + } + + /** + * Flips this buffer. The limit is set to the current position and then + * the position is set to zero. If the mark is defined then it is + * discarded. + *

+ *

After a sequence of channel-read or put operations, invoke + * this method to prepare for a sequence of channel-write or relative + * get operations. For example: + *

+ *

+	 * buf.put(magic);    // Prepend header
+	 * in.read(buf);      // Read data into rest of buffer
+	 * buf.flip();        // Flip buffer
+	 * out.write(buf);    // Write header + data to channel
+ *

+ *

This method is often used in conjunction with the {@link + * java.nio.ByteBuffer#compact compact} method when transferring data from + * one place to another.

+ * + * @return This buffer + */ + public final PointerBuffer flip() { + view.flip(); + return this; + } + + /** + * Rewinds this buffer. The position is set to zero and the mark is + * discarded. + *

+ *

Invoke this method before a sequence of channel-write or get + * operations, assuming that the limit has already been set + * appropriately. For example: + *

+ *

+	 * out.write(buf);    // Write remaining data
+	 * buf.rewind();      // Rewind buffer
+	 * buf.get(array);    // Copy data into array
+ * + * @return This buffer + */ + public final PointerBuffer rewind() { + view.rewind(); + return this; + } + + /** + * Returns the number of elements between the current position and the + * limit.

+ * + * @return The number of elements remaining in this buffer + */ + public final int remaining() { + return view.remaining(); + } + + /** + * Tells whether there are any elements between the current position and + * the limit.

+ * + * @return true if, and only if, there is at least one element + * remaining in this buffer + */ + public final boolean hasRemaining() { + return view.hasRemaining(); + } + + /** + * Allocates a new pointer buffer. + *

+ *

The new buffer's position will be zero, its limit will be its + * capacity, and its mark will be undefined.

+ * + * @param capacity The new buffer's capacity, in pointers + * + * @return The new pointer buffer + * + * @throws IllegalArgumentException If the capacity is a negative integer + */ + public static PointerBuffer allocateDirect(int capacity) { + return new PointerBuffer(capacity); + } + + /** + * This method is used in slice and duplicate instead of normal object construction, + * so that subclasses can return themselves. + * + * @param source + * + * @return A new PointerBuffer instance + */ + protected PointerBuffer newInstance(final ByteBuffer source) { + return new PointerBuffer(source); + } + + /** + * Creates a new pointer buffer whose content is a shared subsequence of + * this buffer's content. + *

+ *

The content of the new buffer will start at this buffer's current + * position. Changes to this buffer's content will be visible in the new + * buffer, and vice versa; the two buffers' position, limit, and mark + * values will be independent. + *

+ *

The new buffer's position will be zero, its capacity and its limit + * will be the number of longs remaining in this buffer, and its mark + * will be undefined. The new buffer will be direct if, and only if, this + * buffer is direct, and it will be read-only if, and only if, this buffer + * is read-only.

+ * + * @return The new pointer buffer + */ + public PointerBuffer slice() { + final int pointerSize = getPointerSize(); + + pointers.position(view.position() * pointerSize); + pointers.limit(view.limit() * pointerSize); + + try { + // We're slicing in the constructor. + return newInstance(pointers); + } finally { + pointers.clear(); + } + } + + /** + * Creates a new pointer buffer that shares this buffer's content. + *

+ *

The content of the new buffer will be that of this buffer. Changes + * to this buffer's content will be visible in the new buffer, and vice + * versa; the two buffers' position, limit, and mark values will be + * independent. + *

+ *

The new buffer's capacity, limit and position will be + * identical to those of this buffer. The new buffer will be direct if, + * and only if, this buffer is direct, and it will be read-only if, and + * only if, this buffer is read-only.

+ * + * @return The new pointer buffer + */ + public PointerBuffer duplicate() { + final PointerBuffer buffer = newInstance(pointers); + + buffer.position(view.position()); + buffer.limit(view.limit()); + + return buffer; + } + + /** + * Creates a new, read-only pointer buffer that shares this buffer's + * content. + *

+ *

The content of the new buffer will be that of this buffer. Changes + * to this buffer's content will be visible in the new buffer; the new + * buffer itself, however, will be read-only and will not allow the shared + * content to be modified. The two buffers' position, limit, and mark + * values will be independent. + *

+ *

The new buffer's capacity, limit and position will be + * identical to those of this buffer. + *

+ *

If this buffer is itself read-only then this method behaves in + * exactly the same way as the {@link #duplicate duplicate} method.

+ * + * @return The new, read-only pointer buffer + */ + public PointerBuffer asReadOnlyBuffer() { + final PointerBuffer buffer = new PointerBufferR(pointers); + + buffer.position(view.position()); + buffer.limit(view.limit()); + + return buffer; + } + + public boolean isReadOnly() { + return false; + } + + /** + * Relative get method. Reads the long at this buffer's + * current position, and then increments the position.

+ * + * @return The long at the buffer's current position + * + * @throws BufferUnderflowException If the buffer's current position is not smaller than its limit + */ + public long get() { + if ( is64Bit ) + return view64.get(); + else + return view32.get() & 0x00000000FFFFFFFFL; + } + + /** + * Relative put method  (optional operation). + *

+ *

Writes the given long into this buffer at the current + * position, and then increments the position.

+ * + * @param l The long to be written + * + * @return This buffer + * + * @throws BufferOverflowException If this buffer's current position is not smaller than its limit + * @throws ReadOnlyBufferException If this buffer is read-only + */ + public PointerBuffer put(long l) { + if ( is64Bit ) + view64.put(l); + else + view32.put((int)l); + return this; + } + + /** + * Convenience put that accepts PointerWrapper objects. + * + * @see #put(long) + */ + public PointerBuffer put(final PointerWrapper pointer) { + return put(pointer.getPointer()); + } + + /** + * Convenience put on a target ByteBuffer. + * + * @param target the target ByteBuffer + * @param l the long value to be written + */ + public static void put(final ByteBuffer target, long l) { + if ( is64Bit ) + target.putLong(l); + else + target.putInt((int)l); + } + + /** + * Absolute get method. Reads the long at the given + * index.

+ * + * @param index The index from which the long will be read + * + * @return The long at the given index + * + * @throws IndexOutOfBoundsException If index is negative + * or not smaller than the buffer's limit + */ + public long get(int index) { + if ( is64Bit ) + return view64.get(index); + else + return view32.get(index) & 0x00000000FFFFFFFFL; + } + + /** + * Absolute put method  (optional operation). + *

+ *

Writes the given long into this buffer at the given + * index.

+ * + * @param index The index at which the long will be written + * @param l The long value to be written + * + * @return This buffer + * + * @throws IndexOutOfBoundsException If index is negative + * or not smaller than the buffer's limit + * @throws ReadOnlyBufferException If this buffer is read-only + */ + public PointerBuffer put(int index, long l) { + if ( is64Bit ) + view64.put(index, l); + else + view32.put(index, (int)l); + return this; + } + + /** + * Convenience put that accepts PointerWrapper objects. + * + * @see #put(int, long) + */ + public PointerBuffer put(int index, PointerWrapper pointer) { + return put(index, pointer.getPointer()); + } + + /** + * Convenience put on a target ByteBuffer. + * + * @param target the target ByteBuffer + * @param index the index at which the long will be written + * @param l the long value to be written + */ + public static void put(final ByteBuffer target, int index, long l) { + if ( is64Bit ) + target.putLong(index * 8, l); + else + target.putInt(index * 4, (int)l); + } + + // -- Bulk get operations -- + + /** + * Relative bulk get method. + *

+ *

This method transfers longs from this buffer into the given + * destination array. If there are fewer longs remaining in the + * buffer than are required to satisfy the request, that is, if + * length > remaining(), then no + * longs are transferred and a {@link BufferUnderflowException} is + * thrown. + *

+ *

Otherwise, this method copies length longs from this + * buffer into the given array, starting at the current position of this + * buffer and at the given offset in the array. The position of this + * buffer is then incremented by length. + *

+ *

In other words, an invocation of this method of the form + * src.get(dst, off, len) has exactly the same effect as + * the loop + *

+ *

+	 *     for (int i = off; i < off + len; i++)
+	 *         dst[i] = src.get(); 
+ *

+ * except that it first checks that there are sufficient longs in + * this buffer and it is potentially much more efficient.

+ * + * @param dst The array into which longs are to be written + * @param offset The offset within the array of the first long to be + * written; must be non-negative and no larger than + * dst.length + * @param length The maximum number of longs to be written to the given + * array; must be non-negative and no larger than + * dst.length - offset + * + * @return This buffer + * + * @throws BufferUnderflowException If there are fewer than length longs + * remaining in this buffer + * @throws IndexOutOfBoundsException If the preconditions on the offset and length + * parameters do not hold + */ + public PointerBuffer get(long[] dst, int offset, int length) { + if ( is64Bit ) + view64.get(dst, offset, length); + else { + checkBounds(offset, length, dst.length); + if ( length > view32.remaining() ) + throw new BufferUnderflowException(); + int end = offset + length; + for ( int i = offset; i < end; i++ ) + dst[i] = view32.get() & 0x00000000FFFFFFFFL; + } + + return this; + } + + /** + * Relative bulk get method. + *

+ *

This method transfers longs from this buffer into the given + * destination array. An invocation of this method of the form + * src.get(a) behaves in exactly the same way as the invocation + *

+ *

+	 *     src.get(a, 0, a.length) 
+ * + * @return This buffer + * + * @throws BufferUnderflowException If there are fewer than length longs + * remaining in this buffer + */ + public PointerBuffer get(long[] dst) { + return get(dst, 0, dst.length); + } + + /** + * Relative bulk put method  (optional operation). + *

+ *

This method transfers the longs remaining in the given source + * buffer into this buffer. If there are more longs remaining in the + * source buffer than in this buffer, that is, if + * src.remaining() > remaining(), + * then no longs are transferred and a {@link + * BufferOverflowException} is thrown. + *

+ *

Otherwise, this method copies + * n = src.remaining() longs from the given + * buffer into this buffer, starting at each buffer's current position. + * The positions of both buffers are then incremented by n. + *

+ *

In other words, an invocation of this method of the form + * dst.put(src) has exactly the same effect as the loop + *

+ *

+	 *     while (src.hasRemaining())
+	 *         dst.put(src.get()); 
+ *

+ * except that it first checks that there is sufficient space in this + * buffer and it is potentially much more efficient.

+ * + * @param src The source buffer from which longs are to be read; + * must not be this buffer + * + * @return This buffer + * + * @throws BufferOverflowException If there is insufficient space in this buffer + * for the remaining longs in the source buffer + * @throws IllegalArgumentException If the source buffer is this buffer + * @throws ReadOnlyBufferException If this buffer is read-only + */ + public PointerBuffer put(PointerBuffer src) { + if ( is64Bit ) + view64.put(src.view64); + else + view32.put(src.view32); + return this; + } + + /** + * Relative bulk put method  (optional operation). + *

+ *

This method transfers longs into this buffer from the given + * source array. If there are more longs to be copied from the array + * than remain in this buffer, that is, if + * length > remaining(), then no + * longs are transferred and a {@link BufferOverflowException} is + * thrown. + *

+ *

Otherwise, this method copies length longs from the + * given array into this buffer, starting at the given offset in the array + * and at the current position of this buffer. The position of this buffer + * is then incremented by length. + *

+ *

In other words, an invocation of this method of the form + * dst.put(src, off, len) has exactly the same effect as + * the loop + *

+ *

+	 *     for (int i = off; i < off + len; i++)
+	 *         dst.put(a[i]); 
+ *

+ * except that it first checks that there is sufficient space in this + * buffer and it is potentially much more efficient.

+ * + * @param src The array from which longs are to be read + * @param offset The offset within the array of the first long to be read; + * must be non-negative and no larger than array.length + * @param length The number of longs to be read from the given array; + * must be non-negative and no larger than + * array.length - offset + * + * @return This buffer + * + * @throws BufferOverflowException If there is insufficient space in this buffer + * @throws IndexOutOfBoundsException If the preconditions on the offset and length + * parameters do not hold + * @throws ReadOnlyBufferException If this buffer is read-only + */ + public PointerBuffer put(long[] src, int offset, int length) { + if ( is64Bit ) + view64.put(src, offset, length); + else { + checkBounds(offset, length, src.length); + if ( length > view32.remaining() ) + throw new BufferOverflowException(); + int end = offset + length; + for ( int i = offset; i < end; i++ ) + view32.put((int)src[i]); + } + + return this; + } + + /** + * Relative bulk put method  (optional operation). + *

+ *

This method transfers the entire content of the given source + * long array into this buffer. An invocation of this method of the + * form dst.put(a) behaves in exactly the same way as the + * invocation + *

+ *

+	 *     dst.put(a, 0, a.length) 
+ * + * @return This buffer + * + * @throws BufferOverflowException If there is insufficient space in this buffer + * @throws ReadOnlyBufferException If this buffer is read-only + */ + public final PointerBuffer put(long[] src) { + return put(src, 0, src.length); + } + + /** + * Compacts this buffer  (optional operation). + *

+ *

The longs between the buffer's current position and its limit, + * if any, are copied to the beginning of the buffer. That is, the + * long at index p = position() is copied + * to index zero, the long at index p + 1 is copied + * to index one, and so forth until the long at index + * limit() - 1 is copied to index + * n = limit() - 1 - p. + * The buffer's position is then set to n+1 and its limit is set to + * its capacity. The mark, if defined, is discarded. + *

+ *

The buffer's position is set to the number of longs copied, + * rather than to zero, so that an invocation of this method can be + * followed immediately by an invocation of another relative put + * method.

+ * + * @return This buffer + * + * @throws ReadOnlyBufferException If this buffer is read-only + */ + public PointerBuffer compact() { + if ( is64Bit ) + view64.compact(); + else + view32.compact(); + return this; + } + + /** + * Retrieves this buffer's byte order. + *

+ *

The byte order of a pointer buffer created by allocation or by + * wrapping an existing long array is the {@link + * ByteOrder#nativeOrder native order} of the underlying + * hardware. The byte order of a pointer buffer created as a view of a byte buffer is that of the + * byte buffer at the moment that the view is created.

+ * + * @return This buffer's byte order + */ + public ByteOrder order() { + if ( is64Bit ) + return view64.order(); + else + return view32.order(); + } + + /** + * Returns a string summarizing the state of this buffer.

+ * + * @return A summary string + */ + public String toString() { + StringBuffer sb = new StringBuffer(48); + sb.append(getClass().getName()); + sb.append("[pos="); + sb.append(position()); + sb.append(" lim="); + sb.append(limit()); + sb.append(" cap="); + sb.append(capacity()); + sb.append("]"); + return sb.toString(); + } + + /** + * Returns the current hash code of this buffer. + *

+ *

The hash code of a pointer buffer depends only upon its remaining + * elements; that is, upon the elements from position() up to, and + * including, the element at limit() - 1. + *

+ *

Because buffer hash codes are content-dependent, it is inadvisable + * to use buffers as keys in hash maps or similar data structures unless it + * is known that their contents will not change.

+ * + * @return The current hash code of this buffer + */ + public int hashCode() { + int h = 1; + int p = position(); + for ( int i = limit() - 1; i >= p; i-- ) + h = 31 * h + (int)get(i); + return h; + } + + /** + * Tells whether or not this buffer is equal to another object. + *

+ *

Two pointer buffers are equal if, and only if, + *

+ *

    + *

    + *

  1. They have the same element type,

  2. + *

    + *

  3. They have the same number of remaining elements, and + *

  4. + *

    + *

  5. The two sequences of remaining elements, considered + * independently of their starting positions, are pointwise equal. + *

  6. + *

    + *

+ *

+ *

A pointer buffer is not equal to any other type of object.

+ * + * @param ob The object to which this buffer is to be compared + * + * @return true if, and only if, this buffer is equal to the + * given object + */ + public boolean equals(Object ob) { + if ( !(ob instanceof PointerBuffer) ) + return false; + PointerBuffer that = (PointerBuffer)ob; + if ( this.remaining() != that.remaining() ) + return false; + int p = this.position(); + for ( int i = this.limit() - 1, j = that.limit() - 1; i >= p; i--, j-- ) { + long v1 = this.get(i); + long v2 = that.get(j); + if ( v1 != v2 ) { + return false; + } + } + return true; + } + + /** + * Compares this buffer to another. + *

+ *

Two pointer buffers are compared by comparing their sequences of + * remaining elements lexicographically, without regard to the starting + * position of each sequence within its corresponding buffer. + *

+ *

A pointer buffer is not comparable to any other type of object. + * + * @return A negative integer, zero, or a positive integer as this buffer + * is less than, equal to, or greater than the given buffer + */ + public int compareTo(Object o) { + final PointerBuffer that = (PointerBuffer)o; + int n = this.position() + Math.min(this.remaining(), that.remaining()); + for ( int i = this.position(), j = that.position(); i < n; i++, j++ ) { + long v1 = this.get(i); + long v2 = that.get(j); + if ( v1 == v2 ) + continue; + if ( v1 < v2 ) + return -1; + return +1; + } + return this.remaining() - that.remaining(); + } + + private static void checkBounds(int off, int len, int size) { + if ( (off | len | (off + len) | (size - (off + len))) < 0 ) + throw new IndexOutOfBoundsException(); + } + + /** + * Read-only version of PointerBuffer. + * + * @author Spasi + */ + private static final class PointerBufferR extends PointerBuffer { + + PointerBufferR(final ByteBuffer source) { + super(source); + } + + public boolean isReadOnly() { + return true; + } + + protected PointerBuffer newInstance(final ByteBuffer source) { + return new PointerBufferR(source); + } + + public PointerBuffer asReadOnlyBuffer() { + return duplicate(); + } + + public PointerBuffer put(final long l) { + throw new ReadOnlyBufferException(); + } + + public PointerBuffer put(final int index, final long l) { + throw new ReadOnlyBufferException(); + } + + public PointerBuffer put(final PointerBuffer src) { + throw new ReadOnlyBufferException(); + } + + public PointerBuffer put(final long[] src, final int offset, final int length) { + throw new ReadOnlyBufferException(); + } + + public PointerBuffer compact() { + throw new ReadOnlyBufferException(); + } + + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/PointerWrapper.java b/src/java/org/lwjgl/PointerWrapper.java similarity index 93% rename from src/java/org/lwjgl/opengl/PointerWrapper.java rename to src/java/org/lwjgl/PointerWrapper.java index 123c6028..25bad96c 100644 --- a/src/java/org/lwjgl/opengl/PointerWrapper.java +++ b/src/java/org/lwjgl/PointerWrapper.java @@ -29,9 +29,13 @@ * 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; +package org.lwjgl; -/** @author spasi */ +/** + * A common interface for classes that wrap pointer addresses. + * + * @author Spasi + */ public interface PointerWrapper { long getPointer(); diff --git a/src/java/org/lwjgl/PointerWrapperAbstract.java b/src/java/org/lwjgl/PointerWrapperAbstract.java new file mode 100644 index 00000000..2f718bd7 --- /dev/null +++ b/src/java/org/lwjgl/PointerWrapperAbstract.java @@ -0,0 +1,75 @@ +/* + * 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; + +/** + * Base PointerWrapper implementation. + * + * @author Spasi + */ +public abstract class PointerWrapperAbstract implements PointerWrapper { + + protected final long pointer; + + protected PointerWrapperAbstract(final long pointer) { + this.pointer = pointer; + } + + public final boolean isNull() { + return pointer == 0; + } + + public final void checkNull() { + if ( LWJGLUtil.DEBUG && pointer == 0 ) + throw new IllegalStateException("This pointer is null."); + } + + public long getPointer() { + return pointer; + } + + public boolean equals(final Object o) { + if ( this == o ) return true; + if ( !(o instanceof PointerWrapperAbstract) ) return false; + + final PointerWrapperAbstract that = (PointerWrapperAbstract)o; + + if ( pointer != that.pointer ) return false; + + return true; + } + + public int hashCode() { + return (int)(pointer ^ (pointer >>> 32)); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/Sys.java b/src/java/org/lwjgl/Sys.java index 70681fd4..59ba4f23 100644 --- a/src/java/org/lwjgl/Sys.java +++ b/src/java/org/lwjgl/Sys.java @@ -56,17 +56,18 @@ public final class Sys { /** Current version of library */ private static final String VERSION = "2.6"; - /** The implementation instance to delegate platform specific behavior to */ - private final static SysImplementation implementation; + private static final String POSTFIX64BIT = "64"; + + /** The implementation instance to delegate platform specific behavior to */ + private static final SysImplementation implementation; + private static final boolean is64Bit; - private final static String POSTFIX64BIT = "64"; - private static void doLoadLibrary(final String lib_name) { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { String library_path = System.getProperty("org.lwjgl.librarypath"); if (library_path != null) { - System.load(library_path + File.separator + + System.load(library_path + File.separator + System.mapLibraryName(lib_name)); } else { System.loadLibrary(lib_name); @@ -76,14 +77,15 @@ public final class Sys { }); } - private static void loadLibrary(final String lib_name) { + private static boolean loadLibrary(final String lib_name) { try { doLoadLibrary(lib_name); + return false; } catch (UnsatisfiedLinkError e) { if (implementation.has64Bit()) { try { doLoadLibrary(lib_name + POSTFIX64BIT); - return; + return true; } catch (UnsatisfiedLinkError e2) { LWJGLUtil.log("Failed to load 64 bit library: " + e2.getMessage()); } @@ -91,12 +93,12 @@ public final class Sys { // Throw original error throw e; } - } + } static { implementation = createImplementation(); - loadLibrary(JNI_LIBRARY_NAME); - + is64Bit = loadLibrary(JNI_LIBRARY_NAME); + int native_jni_version = implementation.getJNIVersion(); int required_version = implementation.getRequiredJNIVersion(); if (native_jni_version != required_version) @@ -130,13 +132,18 @@ public final class Sys { public static String getVersion() { return VERSION; } - + /** * Initialization. This is just a dummy method to trigger the static constructor. */ public static void initialize() { } + /** Returns true if a 64bit implementation was loaded. */ + public static boolean is64Bit() { + return is64Bit; + } + /** * Obtains the number of ticks that the hires timer does in a second. This method is fast; * it should be called as frequently as possible, as it recalibrates the timer. diff --git a/src/java/org/lwjgl/opencl/APIUtil.java b/src/java/org/lwjgl/opencl/APIUtil.java new file mode 100644 index 00000000..e53edf87 --- /dev/null +++ b/src/java/org/lwjgl/opencl/APIUtil.java @@ -0,0 +1,580 @@ +/* + * 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.BufferUtils; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.PointerBuffer; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.nio.*; +import java.nio.charset.Charset; +import java.nio.charset.CharsetEncoder; +import java.util.*; + +/** + * Utility class for OpenCL API calls. + * TODO: Remove useless stuff + * + * @author spasi + */ +final class APIUtil { + + 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 arrayTL = new ThreadLocal() { + protected char[] initialValue() { return new char[INITIAL_BUFFER_SIZE]; } + }; + + private static final ThreadLocal bufferByteTL = new ThreadLocal() { + protected ByteBuffer initialValue() { return BufferUtils.createByteBuffer(INITIAL_BUFFER_SIZE); } + }; + + private static final ThreadLocal bufferPointerTL = new ThreadLocal() { + protected PointerBuffer initialValue() { return BufferUtils.createPointerBuffer(INITIAL_BUFFER_SIZE); } + }; + + private static final ThreadLocal lengthsTL = new ThreadLocal() { + protected PointerBuffer initialValue() { return BufferUtils.createPointerBuffer(INITIAL_LENGTHS_SIZE); } + }; + + private static final ThreadLocal infiniteSeqTL = new ThreadLocal() { + protected InfiniteCharSequence initialValue() { return new InfiniteCharSequence(); } + }; + + private static final ThreadLocal buffersTL = new ThreadLocal() { + protected Buffers initialValue() { return new Buffers(); } + }; + + private static final CharsetEncoder encoder = Charset.forName("US-ASCII").newEncoder(); + + private static final ObjectDestructor DESTRUCTOR_CLSubDevice = new ObjectDestructor() { + public void release(final CLDevice object) { EXTDeviceFission.clReleaseDeviceEXT(object); } + }; + private static final ObjectDestructor DESTRUCTOR_CLMem = new ObjectDestructor() { + public void release(final CLMem object) { CL10.clReleaseMemObject(object); } + }; + private static final ObjectDestructor DESTRUCTOR_CLCommandQueue = new ObjectDestructor() { + public void release(final CLCommandQueue object) { CL10.clReleaseCommandQueue(object); } + }; + private static final ObjectDestructor DESTRUCTOR_CLSampler = new ObjectDestructor() { + public void release(final CLSampler object) { CL10.clReleaseSampler(object); } + }; + private static final ObjectDestructor DESTRUCTOR_CLProgram = new ObjectDestructor() { + public void release(final CLProgram object) { CL10.clReleaseProgram(object); } + }; + private static final ObjectDestructor DESTRUCTOR_CLKernel = new ObjectDestructor() { + public void release(final CLKernel object) { CL10.clReleaseKernel(object); } + }; + private static final ObjectDestructor DESTRUCTOR_CLEvent = new ObjectDestructor() { + public void release(final CLEvent object) { CL10.clReleaseEvent(object); } + }; + + private APIUtil() { + } + + private static char[] getArray(final int size) { + char[] array = arrayTL.get(); + + if ( array.length < size ) { + int sizeNew = array.length << 1; + while ( sizeNew < size ) + sizeNew <<= 1; + + array = new char[size]; + arrayTL.set(array); + } + + return array; + } + + static ByteBuffer getBufferByte(final int size) { + ByteBuffer buffer = bufferByteTL.get(); + + if ( buffer.capacity() < size ) { + int sizeNew = buffer.capacity() << 1; + while ( sizeNew < size ) + sizeNew <<= 1; + + buffer = BufferUtils.createByteBuffer(size); + bufferByteTL.set(buffer); + } else + buffer.clear(); + + return buffer; + } + + private static ByteBuffer getBufferByteOffset(final int size) { + ByteBuffer buffer = bufferByteTL.get(); + + if ( buffer.capacity() < size ) { + int sizeNew = buffer.capacity() << 1; + while ( sizeNew < size ) + sizeNew <<= 1; + + final ByteBuffer bufferNew = BufferUtils.createByteBuffer(size); + bufferNew.put(buffer); + bufferByteTL.set(buffer = bufferNew); + } else { + buffer.position(buffer.limit()); + buffer.limit(buffer.capacity()); + } + + return buffer; + } + + static PointerBuffer getBufferPointer(final int size) { + PointerBuffer buffer = bufferPointerTL.get(); + + if ( buffer.capacity() < size ) { + int sizeNew = buffer.capacity() << 1; + while ( sizeNew < size ) + sizeNew <<= 1; + + buffer = BufferUtils.createPointerBuffer(size); + bufferPointerTL.set(buffer); + } else + buffer.clear(); + + return buffer; + } + + static ShortBuffer getBufferShort() { return buffersTL.get().shorts; } + + static IntBuffer getBufferInt() { return buffersTL.get().ints; } + + static IntBuffer getBufferIntDebug() { return buffersTL.get().intsDebug; } + + static LongBuffer getBufferLong() { return buffersTL.get().longs; } + + static FloatBuffer getBufferFloat() { return buffersTL.get().floats; } + + static DoubleBuffer getBufferDouble() { return buffersTL.get().doubles; } + + static PointerBuffer getBufferPointer() { return buffersTL.get().pointers; } + + static PointerBuffer getLengths() { + return getLengths(1); + } + + static PointerBuffer getLengths(final int size) { + PointerBuffer lengths = lengthsTL.get(); + + if ( lengths.capacity() < size ) { + int sizeNew = lengths.capacity(); + while ( sizeNew < size ) + sizeNew <<= 1; + + lengths = BufferUtils.createPointerBuffer(size); + lengthsTL.set(lengths); + } else + lengths.clear(); + + return lengths; + } + + private static InfiniteCharSequence getInfiniteSeq() { + return infiniteSeqTL.get(); + } + + private static void encode(final ByteBuffer buffer, final CharSequence string) { + final InfiniteCharSequence infiniteSeq = getInfiniteSeq(); + infiniteSeq.setString(string); + encoder.encode(infiniteSeq.buffer, buffer, true); + infiniteSeq.clear(); + } + + /** + * Reads a byte string from the specified buffer. + * + * @param buffer + * + * @return the buffer as a String. + */ + static String getString(final ByteBuffer buffer) { + final int length = buffer.remaining(); + final char[] charArray = getArray(length); + + for ( int i = buffer.position(); i < buffer.limit(); i++ ) + charArray[i - buffer.position()] = (char)buffer.get(i); + + return new String(charArray, 0, length); + } + + /** + * Returns a buffer containing the specified string as bytes. + * + * @param string + * + * @return the String as a ByteBuffer + */ + static ByteBuffer getBuffer(final CharSequence string) { + final ByteBuffer buffer = getBufferByte(string.length()); + + encode(buffer, string); + + buffer.flip(); + return buffer; + } + + /** + * Returns a buffer containing the specified string as bytes, starting at the specified offset. + * + * @param string + * + * @return the String as a ByteBuffer + */ + static ByteBuffer getBuffer(final CharSequence string, final int offset) { + final ByteBuffer buffer = getBufferByteOffset(offset + string.length()); + + encode(buffer, string); + + buffer.flip(); + return buffer; + } + + /** + * Returns a buffer containing the specified string as bytes, including null-termination. + * + * @param string + * + * @return the String as a ByteBuffer + */ + static ByteBuffer getBufferNT(final CharSequence string) { + final ByteBuffer buffer = getBufferByte(string.length() + 1); + + encode(buffer, string); + + buffer.put((byte)0); + buffer.flip(); + return buffer; + } + + static int getTotalLength(final CharSequence[] strings) { + int length = 0; + for ( int i = 0; i < strings.length; i++ ) + length += strings[i].length(); + + return length; + } + + /** + * Returns a buffer containing the specified strings as bytes. + * + * @param strings + * + * @return the Strings as a ByteBuffer + */ + static ByteBuffer getBuffer(final CharSequence[] strings) { + final ByteBuffer buffer = getBufferByte(getTotalLength(strings)); + + final InfiniteCharSequence infiniteSeq = getInfiniteSeq(); + for ( int i = 0; i < strings.length; i++ ) { + infiniteSeq.setString(strings[i]); + encoder.encode(infiniteSeq.buffer, buffer, true); + } + infiniteSeq.clear(); + + buffer.flip(); + return buffer; + } + + /** + * Returns a buffer containing the specified strings as bytes, including null-termination. + * + * @param strings + * + * @return the Strings as a ByteBuffer + */ + static ByteBuffer getBufferNT(final CharSequence[] strings) { + final ByteBuffer buffer = getBufferByte(getTotalLength(strings) + strings.length); + + final InfiniteCharSequence infiniteSeq = getInfiniteSeq(); + for ( int i = 0; i < strings.length; i++ ) { + infiniteSeq.setString(strings[i]); + encoder.encode(infiniteSeq.buffer, buffer, true); + buffer.put((byte)0); + } + infiniteSeq.clear(); + + buffer.flip(); + return buffer; + } + + /** + * Returns a buffer containing the lengths of the specified strings. + * + * @param strings + * + * @return the String lengths in a PointerBuffer + */ + static PointerBuffer getLengths(final CharSequence[] strings) { + PointerBuffer buffer = getLengths(strings.length); + + for ( int i = 0; i < strings.length; i++ ) + buffer.put(strings[i].length()); + + buffer.flip(); + return buffer; + } + + /** + * Returns a buffer containing the lengths of the specified buffers. + * + * @param buffers the buffer array + * + * @return the buffer lengths in a PointerBuffer + */ + static PointerBuffer getLengths(final ByteBuffer[] buffers) { + PointerBuffer buffer = getLengths(buffers.length); + + for ( int i = 0; i < buffers.length; i++ ) + buffer.put(buffers[i].remaining()); + + buffer.flip(); + return buffer; + } + + static int getSize(final PointerBuffer lengths) { + long size = 0; + for ( int i = lengths.position(); i < lengths.limit(); i++ ) + size += lengths.get(i); + + return (int)size; + } + + static void getClassTokens(final Class[] tokenClasses, final Map target, final TokenFilter filter) { + getClassTokens(Arrays.asList(tokenClasses), target, filter); + } + + static void getClassTokens(final Iterable tokenClasses, final Map target, final TokenFilter filter) { + final int TOKEN_MODIFIERS = Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL; + + for ( final Class tokenClass : tokenClasses ) { + for ( final Field field : tokenClass.getDeclaredFields() ) { + // Get only fields. + if ( (field.getModifiers() & TOKEN_MODIFIERS) == TOKEN_MODIFIERS && field.getType() == int.class ) { + try { + final int value = field.getInt(null); + if ( filter != null && !filter.accept(field, value) ) + continue; + + if ( target.containsKey(value) ) // Print colliding tokens in their hex representation. + target.put(value, "0x" + Integer.toHexString(value).toUpperCase()); + else + target.put(value, field.getName()); + } catch (IllegalAccessException e) { + // Ignore + } + } + } + } + } + + static ByteBuffer getNativeKernelArgs(final long user_func_ref, final CLMem[] clMems, final long[] sizes) { + final ByteBuffer args = getBufferByte(8 + 4 + (clMems == null ? 0 : clMems.length * (4 + PointerBuffer.getPointerSize()))); + + args.putLong(0, user_func_ref); + if ( clMems == null ) + args.putInt(8, 0); + else { + args.putInt(8, clMems.length); + int byteIndex = 12; + for ( int i = 0; i < clMems.length; i++ ) { + if ( LWJGLUtil.DEBUG && !clMems[i].isValid() ) + throw new IllegalArgumentException("An invalid CLMem object was specified."); + args.putInt(byteIndex, (int)sizes[i]); // CLMem size + byteIndex += (4 + PointerBuffer.getPointerSize()); // Skip size and make room for the pointer + } + } + + return args; + } + + /** + * Releases all sub-devices created from the specified CLDevice. + * + * @param device the CLDevice to clear + */ + static void releaseObjects(final CLDevice device) { + // Release objects only if we're about to hit 0. + if ( device.getReferenceCount() > 1 ) + return; + + releaseObjects(device.getSubCLDeviceRegistry(), DESTRUCTOR_CLSubDevice); + } + + /** + * Releases all objects contained in the specified CLContext. + * + * @param context the CLContext to clear + */ + static void releaseObjects(final CLContext context) { + // Release objects only if we're about to hit 0. + if ( context.getReferenceCount() > 1 ) + return; + + releaseObjects(context.getCLEventRegistry(), DESTRUCTOR_CLEvent); + releaseObjects(context.getCLProgramRegistry(), DESTRUCTOR_CLProgram); + releaseObjects(context.getCLSamplerRegistry(), DESTRUCTOR_CLSampler); + releaseObjects(context.getCLMemRegistry(), DESTRUCTOR_CLMem); + releaseObjects(context.getCLCommandQueueRegistry(), DESTRUCTOR_CLCommandQueue); + } + + /** + * Releases all objects contained in the specified CLProgram. + * + * @param program the CLProgram to clear + */ + static void releaseObjects(final CLProgram program) { + // Release objects only if we're about to hit 0. + if ( program.getReferenceCount() > 1 ) + return; + + releaseObjects(program.getCLKernelRegistry(), DESTRUCTOR_CLKernel); + } + + /** + * Releases all objects contained in the specified CLCommandQueue. + * + * @param queue the CLCommandQueue to clear + */ + static void releaseObjects(final CLCommandQueue queue) { + // Release objects only if we're about to hit 0. + if ( queue.getReferenceCount() > 1 ) + return; + + releaseObjects(queue.getCLEventRegistry(), DESTRUCTOR_CLEvent); + } + + static Set getExtensions(final String extensionList) { + final Set extensions = new HashSet(); + + final StringTokenizer tokenizer = new StringTokenizer(extensionList); + while ( tokenizer.hasMoreTokens() ) + extensions.add(tokenizer.nextToken()); + + return extensions; + } + + private static void releaseObjects(final CLObjectRegistry registry, final ObjectDestructor destructor) { + if ( registry.isEmpty() ) + return; + + for ( final T object : registry.getAll() ) { + while ( object.isValid() ) + destructor.release(object); + } + } + + private interface ObjectDestructor { + + void release(T object); + + } + + /** + * A mutable CharSequence with very large initial length. We can wrap this in a re-usable CharBuffer for decoding. + * We cannot subclass CharBuffer because of {@link java.nio.CharBuffer#toString(int,int)}. + */ + private static class InfiniteCharSequence implements CharSequence { + + final CharBuffer buffer; + + CharSequence string; + + InfiniteCharSequence() { + buffer = CharBuffer.wrap(this); + } + + void setString(final CharSequence string) { + this.string = string; + this.buffer.position(0); + this.buffer.limit(string.length()); + } + + void clear() { + this.string = null; + } + + public int length() { + return Integer.MAX_VALUE; + } + + public char charAt(final int index) { + return string.charAt(index); + } + + public CharSequence subSequence(final int start, final int end) { + return string.subSequence(start, end); + } + } + + private static class Buffers { + + final ShortBuffer shorts; + final IntBuffer ints; + final IntBuffer intsDebug; + final LongBuffer longs; + + final FloatBuffer floats; + final DoubleBuffer doubles; + + final PointerBuffer pointers; + + Buffers() { + shorts = BufferUtils.createShortBuffer(BUFFERS_SIZE); + ints = BufferUtils.createIntBuffer(BUFFERS_SIZE); + intsDebug = BufferUtils.createIntBuffer(1); + longs = BufferUtils.createLongBuffer(BUFFERS_SIZE); + + floats = BufferUtils.createFloatBuffer(BUFFERS_SIZE); + doubles = BufferUtils.createDoubleBuffer(BUFFERS_SIZE); + + pointers = BufferUtils.createPointerBuffer(BUFFERS_SIZE); + } + + } + + /** Simple interface for Field filtering */ + interface TokenFilter { + + /** Should return true if the specified Field passes the filter. */ + boolean accept(Field field, int value); + + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/APPLEContextLoggingUtil.java b/src/java/org/lwjgl/opencl/APPLEContextLoggingUtil.java new file mode 100644 index 00000000..f69284d6 --- /dev/null +++ b/src/java/org/lwjgl/opencl/APPLEContextLoggingUtil.java @@ -0,0 +1,77 @@ +/* + * 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 java.nio.ByteBuffer; + +/** + * Utility class that provides CLContextCallback implementations that use + * the APPLE_ContextLoggingFunctions callback functions. + *

+ * TODO: Test this class + * + * @author Spasi + */ +public final class APPLEContextLoggingUtil { + + /** Sends all log messages to the Apple System Logger. */ + public static final CLContextCallback SYSTEM_LOG_CALLBACK; + + /** Sends all log messages to the file descriptor stdout. */ + public static final CLContextCallback STD_OUT_CALLBACK; + + /** Sends all log messages to the file descriptor stderr. */ + public static final CLContextCallback STD_ERR_CALLBACK; + + static { + if ( CLCapabilities.isExtensionSupported("CL_APPLE_ContextLoggingFunctions") ) { + SYSTEM_LOG_CALLBACK = new CLContextCallback(CallbackUtil.getLogMessageToSystemLogAPPLE()) { + protected void handleMessage(final String errinfo, final ByteBuffer private_info) { throw new UnsupportedOperationException(); } + }; + + STD_OUT_CALLBACK = new CLContextCallback(CallbackUtil.getLogMessageToStdoutAPPLE()) { + protected void handleMessage(final String errinfo, final ByteBuffer private_info) { throw new UnsupportedOperationException(); } + }; + + STD_ERR_CALLBACK = new CLContextCallback(CallbackUtil.getLogMessageToStderrAPPLE()) { + protected void handleMessage(final String errinfo, final ByteBuffer private_info) { throw new UnsupportedOperationException(); } + }; + } else { + SYSTEM_LOG_CALLBACK = null; + STD_OUT_CALLBACK = null; + STD_ERR_CALLBACK = null; + } + } + + private APPLEContextLoggingUtil() {} + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CL.java b/src/java/org/lwjgl/opencl/CL.java new file mode 100644 index 00000000..981d6c19 --- /dev/null +++ b/src/java/org/lwjgl/opencl/CL.java @@ -0,0 +1,148 @@ +/* + * 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.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.Sys; + +/** + * LWJGL users must use this class to initialize OpenCL + * before using any other class in the org.lwjgl.opencl package. + * + * @author Spasi + */ +public final class CL { + + private static boolean created; + + static { + Sys.initialize(); + } + + private CL() { + } + + /** + * Native method to create CL instance + * + * @param oclPaths Array of strings containing paths to search for OpenCL library + */ + private static native void nCreate(String oclPaths) throws LWJGLException; + + /** + * Native method to create CL instance from the Mac OS X 10.4 OpenCL framework. + * It is only defined in the Mac OS X native library. + */ + private static native void nCreateDefault() throws LWJGLException; + + /** Native method the destroy the CL */ + private static native void nDestroy(); + + /** @return true if CL has been created */ + public static boolean isCreated() { + return created; + } + + public static void create() throws LWJGLException { + if ( created ) + return; + //throw new IllegalStateException("OpenCL has already been created."); + + final String libname; + final String[] library_names; + switch ( LWJGLUtil.getPlatform() ) { + case LWJGLUtil.PLATFORM_WINDOWS: + libname = "OpenCL"; + library_names = new String[] { "OpenCL.dll" }; + break; + case LWJGLUtil.PLATFORM_LINUX: + libname = "OpenCL"; + library_names = new String[] { "libOpenCL64.so", "libOpenCL.so" }; // TODO: Fix this + break; + case LWJGLUtil.PLATFORM_MACOSX: + libname = "OpenCL"; + library_names = new String[] { "OpenCL.dylib" }; // TODO: Fix this + break; + default: + throw new LWJGLException("Unknown platform: " + LWJGLUtil.getPlatform()); + } + + final String[] oclPaths = LWJGLUtil.getLibraryPaths(libname, library_names, CL.class.getClassLoader()); + LWJGLUtil.log("Found " + oclPaths.length + " OpenCL paths"); + for ( int i = 0; i < oclPaths.length; i++ ) { + try { + nCreate(oclPaths[i]); + created = true; + break; + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to load " + oclPaths[i] + ": " + e.getMessage()); + } + } + + if ( !created && LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_MACOSX ) { + // Try to load OpenCL from the framework instead + nCreateDefault(); + created = true; + } + + if ( !created ) + throw new LWJGLException("Could not locate OpenCL library."); + + if ( !CLCapabilities.isExtensionSupported("OpenCL10") ) + throw new RuntimeException("OpenCL 1.0 not supported."); + } + + public static void destroy() { + } + + /** + * Helper method to get a pointer to a named function with aliases in the OpenCL library. + * + * @param aliases the function name aliases. + * + * @return the function pointer address + */ + static long getFunctionAddress(String[] aliases) { + for ( int i = 0; i < aliases.length; i++ ) { + long address = getFunctionAddress(aliases[i]); + if ( address != 0 ) + return address; + } + return 0; + } + + static native long getFunctionAddress(String name); + + private static native void resetNativeStubs(Class clazz); + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLBuildProgramCallback.java b/src/java/org/lwjgl/opencl/CLBuildProgramCallback.java new file mode 100644 index 00000000..0da9c7b0 --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLBuildProgramCallback.java @@ -0,0 +1,63 @@ +/* + * 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; + +/** + * Instances of this class can be used to receive OpenCL program build notifications. + * + * @author Spasi + */ +public abstract class CLBuildProgramCallback extends CLCallback { + + protected CLBuildProgramCallback() { + super(CallbackUtil.getBuildProgramCallback()); + } + + /** + * Called from native code. + * + * @param program_address the CLProgram object pointer + */ + private void handleMessage(long program_address) { + handleMessage(CLContext.getCLProgramGlobal(program_address)); + } + + /** + * The callback method. + * + * @param program the CLProgram object that was built + */ + protected abstract void handleMessage(CLProgram program); + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLCallback.java b/src/java/org/lwjgl/opencl/CLCallback.java new file mode 100644 index 00000000..48aa024b --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLCallback.java @@ -0,0 +1,59 @@ +/* + * 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 diff --git a/src/java/org/lwjgl/opencl/CLChecks.java b/src/java/org/lwjgl/opencl/CLChecks.java new file mode 100644 index 00000000..c1606fff --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLChecks.java @@ -0,0 +1,259 @@ +/* + * 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.LWJGLUtil; +import org.lwjgl.PointerBuffer; + +import java.nio.ByteBuffer; + +/** + * Utility class that provides runtime checks for OpenCL method calls. + * TODO: Revisit this when Java 7.0 is released, there will be new Buffer API with 64bit indices/sizes. + * + * @author Spasi + */ +final class CLChecks { + + private CLChecks() { + } + + /** + * Calculates the number of bytes in the specified cl_mem buffer rectangle region. + * + * @param origin the host origin + * @param region the rectangle region + * @param row_pitch the host row pitch + * @param slice_pitch the host slice pitch + * + * @return the region size in bytes + */ + static int calculateBufferRectSize(final PointerBuffer origin, final PointerBuffer region, long row_pitch, long slice_pitch) { + if ( !LWJGLUtil.CHECKS ) + return 0; + + final long x = origin.get(0); + final long y = origin.get(1); + final long z = origin.get(2); + + if ( x < 0 || y < 0 || z < 0 ) + throw new IllegalArgumentException("Invalid cl_mem host origin: " + x + ", " + y + ", " + z); + + final long w = region.get(0); + final long h = region.get(1); + final long d = region.get(2); + + if ( w < 1 || h < 1 || d < 1 ) + throw new IllegalArgumentException("Invalid cl_mem rectangle region dimensions: " + w + " x " + h + " x " + d); + + if ( row_pitch == 0 ) + row_pitch = w; + else if ( row_pitch < w ) + throw new IllegalArgumentException("Invalid host row pitch specified: " + row_pitch); + + if ( slice_pitch == 0 ) + slice_pitch = row_pitch * h; + else if ( slice_pitch < (row_pitch * h) ) + throw new IllegalArgumentException("Invalid host slice pitch specified: " + slice_pitch); + + return (int)((z * slice_pitch + y * row_pitch + x) + (w * h * d)); + } + + /** + * Calculates the number of bytes in the specified cl_mem image region. + * This implementation assumes 1 byte per element, because we cannot the + * image type. + * + * @param region the image region + * @param row_pitch the row pitch + * @param slice_pitch the slice pitch + * + * @return the region size in bytes + */ + static int calculateImageSize(final PointerBuffer region, long row_pitch, long slice_pitch) { + if ( !LWJGLUtil.CHECKS ) + return 0; + + final long w = region.get(0); + final long h = region.get(1); + final long d = region.get(2); + + if ( w < 1 || h < 1 || d < 1 ) + throw new IllegalArgumentException("Invalid cl_mem image region dimensions: " + w + " x " + h + " x " + d); + + if ( row_pitch == 0 ) + row_pitch = w; + else if ( row_pitch < w ) + throw new IllegalArgumentException("Invalid row pitch specified: " + row_pitch); + + if ( slice_pitch == 0 ) + slice_pitch = row_pitch * h; + else if ( slice_pitch < (row_pitch * h) ) + throw new IllegalArgumentException("Invalid slice pitch specified: " + slice_pitch); + + return (int)(slice_pitch * d); + + } + + /** + * Calculates the number of bytes in the specified 2D image. + * + * @param format the cl_image_format struct + * @param w the image width + * @param h the image height + * @param row_pitch the image row pitch + * + * @return the 2D image size in bytes + */ + static int calculateImage2DSize(final ByteBuffer format, final long w, final long h, long row_pitch) { + if ( LWJGLUtil.CHECKS && (w < 1 || h < 1) ) + throw new IllegalArgumentException("Invalid 2D image dimensions: " + w + " x " + h); + + final int elementSize = getElementSize(format); + + if ( row_pitch == 0 ) + row_pitch = w * elementSize; + else if ( LWJGLUtil.CHECKS && ((row_pitch < w * elementSize) || (row_pitch % elementSize != 0)) ) + throw new IllegalArgumentException("Invalid image_row_pitch specified: " + row_pitch); + + return (int)(row_pitch * h); + } + + /** + * Calculates the number of bytes in the specified 3D image. + * + * @param format the cl_image_format struct + * @param w the image width + * @param h the image height + * @param d the image depth + * @param row_pitch the image row pitch + * @param slice_pitch the image slice pitch + * + * @return the 3D image size in bytes + */ + static int calculateImage3DSize(final ByteBuffer format, final long w, final long h, final long d, long row_pitch, long slice_pitch) { + if ( LWJGLUtil.CHECKS && (w < 1 || h < 1 || d < 2) ) + throw new IllegalArgumentException("Invalid 3D image dimensions: " + w + " x " + h + " x " + d); + + final int elementSize = getElementSize(format); + + if ( row_pitch == 0 ) + row_pitch = w * elementSize; + else if ( LWJGLUtil.CHECKS && ((row_pitch < w * elementSize) || (row_pitch % elementSize != 0)) ) + throw new IllegalArgumentException("Invalid image_row_pitch specified: " + row_pitch); + + if ( slice_pitch == 0 ) + slice_pitch = row_pitch * h; + else if ( LWJGLUtil.CHECKS && ((row_pitch < row_pitch * h) || (slice_pitch % row_pitch != 0)) ) + throw new IllegalArgumentException("Invalid image_slice_pitch specified: " + row_pitch); + + return (int)(slice_pitch * d); + } + + /** + * Returns the number of bytes per element for the specified image format. + * + * @param format a cl_image_format struct. + * + * @return the number of bytes per image element + */ + private static int getElementSize(final ByteBuffer format) { + final int channelOrder = format.getInt(format.position() + 0); + final int channelType = format.getInt(format.position() + 4); + + return getChannelCount(channelOrder) * getChannelSize(channelType); + } + + /** + * Returns the number of channels in the specified cl_channel_order. + * + * @param channelOrder the cl_channel_order + * + * @return the number of channels + */ + private static int getChannelCount(final int channelOrder) { + switch ( channelOrder ) { + case CL10.CL_R: + case CL10.CL_A: + case CL10.CL_INTENSITY: + case CL10.CL_LUMINANCE: + case CL11.CL_Rx: + return 1; + case CL10.CL_RG: + case CL10.CL_RA: + case CL11.CL_RGx: + return 2; + case CL10.CL_RGB: + case CL11.CL_RGBx: + return 3; + case CL10.CL_RGBA: + case CL10.CL_BGRA: + case CL10.CL_ARGB: + return 4; + default: + throw new IllegalArgumentException("Invalid cl_channel_order specified: 0x" + Integer.toHexString(channelOrder).toUpperCase()); + } + } + + /** + * Returns the number of bytes in the specified cl_channel_type. + * + * @param channelType the cl_channel_type + * + * @return the number of bytes + */ + private static int getChannelSize(final int channelType) { + switch ( channelType ) { + case CL10.CL_SNORM_INT8: + case CL10.CL_UNORM_INT8: + case CL10.CL_SIGNED_INT8: + case CL10.CL_UNSIGNED_INT8: + return 1; + case CL10.CL_SNORM_INT16: + case CL10.CL_UNORM_INT16: + case CL10.CL_UNORM_SHORT_565: + case CL10.CL_UNORM_SHORT_555: + case CL10.CL_SIGNED_INT16: + case CL10.CL_UNSIGNED_INT16: + case CL10.CL_HALF_FLOAT: + return 2; + case CL10.CL_UNORM_INT_101010: + case CL10.CL_SIGNED_INT32: + case CL10.CL_UNSIGNED_INT32: + case CL10.CL_FLOAT: + return 4; + default: + throw new IllegalArgumentException("Invalid cl_channel_type specified: 0x" + Integer.toHexString(channelType).toUpperCase()); + } + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLCommandQueue.java b/src/java/org/lwjgl/opencl/CLCommandQueue.java new file mode 100644 index 00000000..f972b00e --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLCommandQueue.java @@ -0,0 +1,97 @@ +/* + * 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.PointerBuffer; + +/** + * This class is a wrapper around a cl_command_queue pointer. + * + * @author Spasi + */ +public final class CLCommandQueue extends CLObjectChild { + + private final CLDevice device; + + private final CLObjectRegistry clEvents; + + CLCommandQueue(final long pointer, final CLContext context, final CLDevice device) { + super(pointer, context); + if ( isValid() ) { + this.device = device; + this.clEvents = new CLObjectRegistryGlobal(CLContext.clEventsGlobal); + context.getCLCommandQueueRegistry().registerObject(this); + } else { + this.device = null; + this.clEvents = null; + } + } + + public CLDevice getCLDevice() { + return device; + } + + /** + * Returns a CLEvent associated with this command-queue. + * + * @param id the event object id + * + * @return the CLEvent object + */ + public CLEvent getCLEvent(final long id) { + return clEvents.getObject(id); + } + + // -------[ IMPLEMENTATION STUFF BELOW ]------- + + CLObjectRegistry getCLEventRegistry() { return clEvents; } + + /** + * Called from OpenCL methods that generate CLEvents. + * + * @param event a buffer containing a CLEvent pointer. + */ + void registerCLEvent(final PointerBuffer event) { + if ( event != null ) + new CLEvent(event.get(event.position()), this); + } + + int release() { + try { + return super.release(); + } finally { + if ( !isValid() ) + getParent().getCLCommandQueueRegistry().unregisterObject(this); + } + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLContext.java b/src/java/org/lwjgl/opencl/CLContext.java new file mode 100644 index 00000000..d36c9466 --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLContext.java @@ -0,0 +1,135 @@ +/* + * 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 java.util.HashMap; +import java.util.Map; + +/** + * This class is a wrapper around a cl_context pointer. + * + * @author Spasi + */ +public final class CLContext extends CLObject { + + private final CLObjectRegistry clCommandQueues; + private final CLObjectRegistry clMems; + private final CLObjectRegistry clSamplers; + private final CLObjectRegistry clPrograms; + private final CLObjectRegistry clEvents; + + /** Global registry for build callbacks. */ + static Map clProgramsGlobal = new HashMap(); + + /** Global registry for event callbacks. */ + static Map clEventsGlobal = new HashMap(); + + CLContext(final long pointer) { + super(pointer); + + if ( isValid() ) { + clCommandQueues = new CLObjectRegistry(); + clMems = new CLObjectRegistry(); + clSamplers = new CLObjectRegistry(); + clPrograms = new CLObjectRegistryGlobal(clProgramsGlobal); + clEvents = new CLObjectRegistryGlobal(clEventsGlobal); + } else { + clCommandQueues = null; + clMems = null; + clSamplers = null; + clPrograms = null; + clEvents = null; + } + } + + /** + * Returns a CLCommandQueue associated with this context. + * + * @param id the command queue object id + * + * @return the CLCommandQueue object + */ + public CLCommandQueue getCLCommandQueue(final long id) { return clCommandQueues.getObject(id); } + + /** + * Returns a CLMem associated with this context. + * + * @param id the memory object id + * + * @return the CLMem object + */ + public CLMem getCLMem(final long id) { return clMems.getObject(id); } + + /** + * Returns a CLSampler associated with this context. + * + * @param id the sampler object id + * + * @return the CLSampler object + */ + public CLSampler getCLSampler(final long id) { return clSamplers.getObject(id); } + + /** + * Returns a CLProgram associated with this context. + * + * @param id the program object id + * + * @return the CLProgram object + */ + public CLProgram getCLProgram(final long id) { return clPrograms.getObject(id); } + + /** + * Returns a user CLEvent associated with this context. + * + * @param id the event object id + * + * @return the CLEvent object + */ + public CLEvent getCLEvent(final long id) { return clEvents.getObject(id); } + + // -------[ IMPLEMENTATION STUFF BELOW ]------- + + CLObjectRegistry getCLCommandQueueRegistry() { return clCommandQueues; } + + CLObjectRegistry getCLMemRegistry() { return clMems; } + + CLObjectRegistry getCLSamplerRegistry() { return clSamplers; } + + CLObjectRegistry getCLProgramRegistry() { return clPrograms; } + + CLObjectRegistry 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 diff --git a/src/java/org/lwjgl/opencl/CLContextCallback.java b/src/java/org/lwjgl/opencl/CLContextCallback.java new file mode 100644 index 00000000..ab33b709 --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLContextCallback.java @@ -0,0 +1,78 @@ +/* + * 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; + +import java.nio.ByteBuffer; + +/** + * Instances of this class can be used to receive OpenCL context error notifications. + * + * @author Spasi + */ +public abstract class CLContextCallback extends PointerWrapperAbstract { + + private final boolean custom; + + protected CLContextCallback() { + super(CallbackUtil.getContextCallback()); + custom = false; + } + + /** + * This constructor allows non-LWJGL implementations. + * + * @param pointer + */ + protected CLContextCallback(final long pointer) { + super(pointer); + + if ( pointer == 0 ) + throw new RuntimeException("Invalid callback function pointer specified."); + + custom = true; + } + + final boolean isCustom() { + return custom; + } + + /** + * The callback method. + * + * @param errinfo the error description + * @param private_info optional error data (may be null) + */ + protected abstract void handleMessage(String errinfo, ByteBuffer private_info); + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLDevice.java b/src/java/org/lwjgl/opencl/CLDevice.java new file mode 100644 index 00000000..a978b1c1 --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLDevice.java @@ -0,0 +1,191 @@ +/* + * 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.PointerBuffer; + +/** + * This class is a wrapper around a cl_device_id pointer. + * + * @author Spasi + */ +public final class CLDevice extends CLObjectChild { + + private static final CLDeviceImpl impl = (CLDeviceImpl)CLPlatform.getClassInstance("org.lwjgl.opencl.CLDeviceImpl"); + + private final CLObjectRegistry subCLDevices; + + private Object caps; + + public CLDevice(final long pointer) { + this(pointer, null); + } + + /** + * EXT_device_fission constructor. + * + * @param pointer the sub-device pointer + * @param parent the parent CLDevice + */ + CLDevice(final long pointer, final CLDevice parent) { + super(pointer, parent); + + if ( isValid() ) { + subCLDevices = new CLObjectRegistry(); + if ( parent != null ) + parent.subCLDevices.registerObject(this); + } else + subCLDevices = null; + } + + void setCapabilities(final Object caps) { + this.caps = caps; + } + + Object getCapabilities() { + return caps; + } + + /** + * Returns a sub-device of this device. + * + * @param id the sub-device object id + * + * @return the CLDevice object + */ + public CLDevice getSubCLDevice(final long id) { return subCLDevices.getObject(id); } + + int retain() { + if ( getParent() == null ) + return getReferenceCount(); // NO-OP, root devices cannot be retained + + return super.retain(); + } + + int release() { + if ( getParent() == null ) + return getReferenceCount(); // NO-OP, root devices cannot be released + + try { + return super.release(); + } finally { + if ( !isValid() ) + getParent().subCLDevices.unregisterObject(this); + } + } + + CLObjectRegistry getSubCLDeviceRegistry() { return subCLDevices; } + + /** + * Called from clCreateSubDevicesEXT to register new sub-devices. + * + * @param devices a buffer containing CLDevice pointers. + */ + void registerSubCLDevices(final PointerBuffer devices) { + for ( int i = devices.position(); i < devices.limit(); i++ ) { + final long pointer = devices.get(i); + if ( pointer != 0 ) + new CLDevice(pointer, this); + } + } + + // ---------------[ HELPER METHODS ]--------------- + + /** + * Returns the value of the specified String parameter. + * + * @param param_name the parameter + * + * @return the parameter value + */ + public String getInfoString(int param_name) { + return impl.getInfoString(this, param_name); + } + + /** + * Returns the integer value of the specified parameter. + * + * @param param_name the parameter + * + * @return the parameter value + */ + public int getInfoInt(int param_name) { + return impl.getInfoInt(this, param_name); + } + + /** + * Returns the boolean value of the specified parameter. + * + * @param param_name the parameter + * + * @return the parameter value + */ + public boolean getInfoBoolean(int param_name) { + return impl.getInfoInt(this, param_name) != 0; + } + + /** + * Returns the size_t value of the specified parameter. + * + * @param param_name the parameter + * + * @return the parameter value + */ + public long getInfoSize(int param_name) { + return impl.getInfoSize(this, param_name); + } + + /** + * Returns the long value of the specified parameter. Can be used + * for both cl_ulong and cl_bitfield parameters. + * + * @param param_name the parameter + * + * @return the parameter value + */ + public long getInfoLong(int param_name) { + return impl.getInfoLong(this, param_name); + } + + /** CLDevice helper methods implementation interface. */ + interface CLDeviceImpl { + + String getInfoString(CLDevice device, int param_name); + + int getInfoInt(CLDevice device, int param_name); + + long getInfoSize(CLDevice device, int param_name); + + long getInfoLong(CLDevice device, int param_name); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLDeviceImpl.java b/src/java/org/lwjgl/opencl/CLDeviceImpl.java new file mode 100644 index 00000000..26e5d15a --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLDeviceImpl.java @@ -0,0 +1,104 @@ +/* + * 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.PointerBuffer; + +import java.nio.ByteBuffer; + +import static org.lwjgl.opencl.CL10.*; + +/** + * Implementation of CLDevice helper methods. + * + * @author Spasi + */ +final class CLDeviceImpl implements CLDevice.CLDeviceImpl { + + CLDeviceImpl() { + } + + static CLDeviceCapabilities getCapabilities(final CLDevice device) { + device.checkValid(); + + CLDeviceCapabilities caps = (CLDeviceCapabilities)device.getCapabilities(); + if ( caps == null ) + device.setCapabilities(caps = new CLDeviceCapabilities(device)); + + return caps; + } + + private static int getInfoBytes(final CLDevice device, final int param_name) { + final PointerBuffer bytes = APIUtil.getBufferPointer(); + clGetDeviceInfo(device, param_name, null, bytes); + return (int)bytes.get(0); + } + + public String getInfoString(final CLDevice device, final int param_name) { + device.checkValid(); + + final int bytes = getInfoBytes(device, param_name); + + final ByteBuffer versionBuffer = APIUtil.getBufferByte(bytes); + clGetDeviceInfo(device, param_name, versionBuffer, null); + + versionBuffer.limit(bytes - 1); // Exclude null-termination + return APIUtil.getString(versionBuffer); + } + + public int getInfoInt(final CLDevice device, final int param_name) { + device.checkValid(); + + final ByteBuffer versionBuffer = APIUtil.getBufferByte(4); + clGetDeviceInfo(device, param_name, versionBuffer, null); + + return versionBuffer.getInt(0); + } + + public long getInfoSize(final CLDevice device, final int param_name) { + device.checkValid(); + + final PointerBuffer pointerBuffer = APIUtil.getBufferPointer(); + clGetDeviceInfo(device, param_name, pointerBuffer.getBuffer(), null); + + return pointerBuffer.get(0); + } + + public long getInfoLong(final CLDevice device, final int param_name) { + device.checkValid(); + + final ByteBuffer versionBuffer = APIUtil.getBufferByte(8); + clGetDeviceInfo(device, param_name, versionBuffer, null); + + return versionBuffer.getLong(0); + } +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLEvent.java b/src/java/org/lwjgl/opencl/CLEvent.java new file mode 100644 index 00000000..d5dc6b13 --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLEvent.java @@ -0,0 +1,86 @@ +/* + * 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; + +/** + * This class is a wrapper around a cl_mem pointer. + * + * @author Spasi + */ +public final class CLEvent extends CLObjectChild { + + private final CLCommandQueue queue; + + CLEvent(final long pointer, final CLContext context) { + this(pointer, context, null); + } + + CLEvent(final long pointer, final CLCommandQueue queue) { + this(pointer, queue.getParent(), queue); + } + + CLEvent(final long pointer, final CLContext context, final CLCommandQueue queue) { + super(pointer, context); + if ( isValid() ) { + this.queue = queue; + if ( queue == null ) + context.getCLEventRegistry().registerObject(this); + else + queue.getCLEventRegistry().registerObject(this); + } else + this.queue = null; + } + + /** + * Returns the command-queue associated with this event. For + * user events this method returns null. + * + * @return the command-queue or null if this is a user event + */ + public CLCommandQueue getCLCommandQueue() { + return queue; + } + + int release() { + try { + return super.release(); + } finally { + if ( !isValid() ) { + if ( queue == null ) + getParent().getCLEventRegistry().unregisterObject(this); + else + queue.getCLEventRegistry().unregisterObject(this); + } + } + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLEventCallback.java b/src/java/org/lwjgl/opencl/CLEventCallback.java new file mode 100644 index 00000000..43bb6651 --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLEventCallback.java @@ -0,0 +1,61 @@ +/* + * 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; + +/** + * Instances of this class can be used to receive OpenCL memory object destruction notifications. + * + * @author Spasi + */ +public abstract class CLEventCallback extends CLCallback { + + protected CLEventCallback() { + super(CallbackUtil.getEventCallback()); + } + + /** + * 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); + } + + /** + * The callback method. + * + * @param event the CLEvent object + */ + protected abstract void handleMessage(CLEvent event, int event_command_exec_status); + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLFunctionAddress.java b/src/java/org/lwjgl/opencl/CLFunctionAddress.java new file mode 100644 index 00000000..77f2c956 --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLFunctionAddress.java @@ -0,0 +1,47 @@ +/* + * 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; + +/** + * This class is a wrapper around an OpenCL extension function pointer. + * + * @author Spasi + */ +final class CLFunctionAddress extends PointerWrapperAbstract { + + CLFunctionAddress(final long pointer) { + super(pointer); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLKernel.java b/src/java/org/lwjgl/opencl/CLKernel.java new file mode 100644 index 00000000..6b272260 --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLKernel.java @@ -0,0 +1,113 @@ +/* + * 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.PointerWrapper; + +/** + * This class is a wrapper around a cl_kernel pointer. + * + * @author Spasi + */ +public final class CLKernel extends CLObjectChild { + + private static final CLKernelImpl impl = (CLKernelImpl)CLPlatform.getClassInstance("org.lwjgl.opencl.CLKernelImpl"); + + CLKernel(final long pointer, final CLProgram program) { + super(pointer, program); + if ( isValid() ) + program.getCLKernelRegistry().registerObject(this); + } + + int release() { + try { + return super.release(); + } finally { + if ( !isValid() ) + getParent().getCLKernelRegistry().unregisterObject(this); + } + } + + public CLKernel setArg(final int index, final byte value) { + impl.setArg(this, index, value); + return this; + } + + public CLKernel setArg(final int index, final short value) { + impl.setArg(this, index, value); + return this; + } + + public CLKernel setArg(final int index, final int value) { + impl.setArg(this, index, value); + return this; + } + + public CLKernel setArg(final int index, final long value) { + impl.setArg(this, index, value); + return this; + } + + public CLKernel setArg(final int index, final float value) { + impl.setArg(this, index, value); + return this; + } + + public CLKernel setArg(final int index, final double value) { + impl.setArg(this, index, value); + return this; + } + + public CLKernel setArg(final int index, final PointerWrapper value) { + impl.setArg(this, index, value); + return this; + } + + interface CLKernelImpl { + + void setArg(CLKernel clKernel, int index, byte value); + + void setArg(CLKernel clKernel, int index, short value); + + void setArg(CLKernel clKernel, int index, int value); + + void setArg(CLKernel clKernel, int index, long value); + + void setArg(CLKernel clKernel, int index, float value); + + void setArg(CLKernel clKernel, int index, double value); + + void setArg(CLKernel clKernel, int index, PointerWrapper pointer); + + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLKernelImpl.java b/src/java/org/lwjgl/opencl/CLKernelImpl.java new file mode 100644 index 00000000..fc2f3695 --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLKernelImpl.java @@ -0,0 +1,77 @@ +/* + * 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.PointerBuffer; +import org.lwjgl.PointerWrapper; + +import static org.lwjgl.opencl.CL10.*; + +/** + * Implementation of CLKernel helper methods. + * + * @author Spasi + */ +final class CLKernelImpl implements CLKernel.CLKernelImpl { + + CLKernelImpl() { + } + + public void setArg(final CLKernel clKernel, final int index, final byte value) { + clSetKernelArg(clKernel, index, 1, APIUtil.getBufferByte(1).put(0, value)); + } + + public void setArg(final CLKernel clKernel, final int index, final short value) { + clSetKernelArg(clKernel, index, 2, APIUtil.getBufferShort().put(0, value)); + } + + public void setArg(final CLKernel clKernel, final int index, final int value) { + clSetKernelArg(clKernel, index, 4, APIUtil.getBufferInt().put(0, value)); + } + + public void setArg(final CLKernel clKernel, final int index, final long value) { + clSetKernelArg(clKernel, index, 8, APIUtil.getBufferLong().put(0, value)); + } + + public void setArg(final CLKernel clKernel, final int index, final float value) { + clSetKernelArg(clKernel, index, 4, APIUtil.getBufferFloat().put(0, value)); + } + + public void setArg(final CLKernel clKernel, final int index, final double value) { + clSetKernelArg(clKernel, index, 8, APIUtil.getBufferDouble().put(0, value)); + } + + public void setArg(final CLKernel clKernel, final int index, final PointerWrapper pointer) { + clSetKernelArg(clKernel, index, PointerBuffer.getPointerSize(), APIUtil.getBufferPointer().put(0, pointer).getBuffer()); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLMem.java b/src/java/org/lwjgl/opencl/CLMem.java new file mode 100644 index 00000000..e94cf7da --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLMem.java @@ -0,0 +1,66 @@ +/* + * 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; + +/** + * This class is a wrapper around a cl_mem pointer. + * + * @author Spasi + */ +public final class CLMem extends CLObjectChild { + + CLMem(final long pointer, final CLContext context) { + super(pointer, context); + if ( isValid() ) + context.getCLMemRegistry().registerObject(this); + } + + static CLMem create(final long pointer, final CLContext context) { + CLMem clMem = context.getCLMemRegistry().getObject(pointer); + if ( clMem == null ) + clMem = new CLMem(pointer, context); + else + clMem.retain(); + + return clMem; + } + + int release() { + try { + return super.release(); + } finally { + if ( !isValid() ) + getParent().getCLMemRegistry().unregisterObject(this); + } + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLMemObjectDestructorCallback.java b/src/java/org/lwjgl/opencl/CLMemObjectDestructorCallback.java new file mode 100644 index 00000000..9e84fd2e --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLMemObjectDestructorCallback.java @@ -0,0 +1,52 @@ +/* + * 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; + +/** + * Instances of this class can be used to receive OpenCL memory object destruction notifications. + * + * @author Spasi + */ +public abstract class CLMemObjectDestructorCallback extends CLCallback { + + protected CLMemObjectDestructorCallback() { + super(CallbackUtil.getMemObjectDestructorCallback()); + } + + /** + * The callback method. + * + * @param memobj id of the CLMem object that was destroyed + */ + protected abstract void handleMessage(long memobj); + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLNativeKernel.java b/src/java/org/lwjgl/opencl/CLNativeKernel.java new file mode 100644 index 00000000..f1375355 --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLNativeKernel.java @@ -0,0 +1,59 @@ +/* + * 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 java.nio.ByteBuffer; + +/** + * Instances of this class can be used to execute native kernels. clEnqueueNativeKernel will build + * the its arguments automatically, in a way that allows execute to receive an array + * of ByteBuffers, pointing to cl_mem objects in global memory. The ByteBuffer objects should not + * be used outside the handleMessage method. + * + * @author Spasi + * @see CL10#clEnqueueNativeKernel + * @see #execute(java.nio.ByteBuffer[]) + */ +public abstract class CLNativeKernel extends CLCallback { + + protected CLNativeKernel() { + super(CallbackUtil.getNativeKernelCallback()); + } + + /** + * Implement this method to execute an action on cl_mem objects in global memory. + * + * @param memobjs an array of ByteBuffers pointing to cl_mem global memory. + */ + protected abstract void execute(ByteBuffer[] memobjs); + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLObject.java b/src/java/org/lwjgl/opencl/CLObject.java new file mode 100644 index 00000000..3377456c --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLObject.java @@ -0,0 +1,88 @@ +/* + * 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.LWJGLUtil; +import org.lwjgl.PointerWrapperAbstract; + +/** + * Base class for all retainable OpenCL objects. + * + * @author Spasi + */ +abstract class CLObject extends PointerWrapperAbstract { + + private int refCount; + + CLObject(final long pointer) { + super(pointer); + + if ( pointer != 0 ) + this.refCount = 1; + } + + public final int getReferenceCount() { + return refCount; + } + + public final boolean isValid() { + return refCount > 0; + } + + public final long getPointer() { + checkValid(); + return super.getPointer(); + } + + final long getPointerUnsafe() { + return super.getPointer(); + } + + int retain() { + checkValid(); + //System.out.println(getClass().getSimpleName() + " REF COUNT: " + pointer + " - " + (refCount + 1)); + return ++refCount; + } + + int release() { + checkValid(); + //System.out.println(getClass().getSimpleName() + " REF COUNT: " + pointer + " - " + (refCount - 1)); + return --refCount; + } + + final void checkValid() { + checkNull(); + if ( LWJGLUtil.DEBUG && refCount == 0 ) + throw new IllegalStateException("This CL object is invalid."); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLObjectChild.java b/src/java/org/lwjgl/opencl/CLObjectChild.java new file mode 100644 index 00000000..c3b8b219 --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLObjectChild.java @@ -0,0 +1,58 @@ +/* + * 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.LWJGLUtil; + +/** + * Base class for all CLObjects that are associated with a parent CLObject. + * + * @author Spasi + */ +abstract class CLObjectChild

extends CLObject { + + private final P parent; + + CLObjectChild(final long pointer, final P parent) { + super(pointer); + + if ( LWJGLUtil.DEBUG && parent != null && !parent.isValid() ) + throw new IllegalStateException("The parent specified is not a valid CL object."); + + this.parent = parent; + } + + public P getParent() { + return parent; + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLObjectRegistry.java b/src/java/org/lwjgl/opencl/CLObjectRegistry.java new file mode 100644 index 00000000..0641983e --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLObjectRegistry.java @@ -0,0 +1,55 @@ +package org.lwjgl.opencl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * A CLContextObject container. + * + * @author Spasi + */ +class CLObjectRegistry { + + private Map registry; + + CLObjectRegistry() { + } + + final boolean isEmpty() { + return registry == null || registry.isEmpty(); + } + + final T getObject(final long id) { + return registry == null ? null : registry.get(id); + } + + final boolean hasObject(final long id) { + return registry != null && registry.containsKey(id); + } + + final List getAll() { + return registry == null ? null : new ArrayList(registry.values()); + } + + void registerObject(final T object) { + final Map map = getMap(); + final Long key = object.getPointer(); + + if ( !map.containsKey(key) ) + getMap().put(object.getPointer(), object); + } + + void unregisterObject(final T object) { + getMap().remove(object.getPointerUnsafe()); + } + + private Map getMap() { + if ( registry == null ) + registry = new HashMap(); + + return registry; + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLObjectRegistryGlobal.java b/src/java/org/lwjgl/opencl/CLObjectRegistryGlobal.java new file mode 100644 index 00000000..24267314 --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLObjectRegistryGlobal.java @@ -0,0 +1,59 @@ +/* + * 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 java.util.Map; + +/** + * A CLObject registry that also registers/unregisters objects to/from a global registry. + * + * @author Spasi + */ +final class CLObjectRegistryGlobal extends CLObjectRegistry { + + private final Map globalRegistry; + + CLObjectRegistryGlobal(final Map 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 diff --git a/src/java/org/lwjgl/opencl/CLPlatform.java b/src/java/org/lwjgl/opencl/CLPlatform.java new file mode 100644 index 00000000..65880a15 --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLPlatform.java @@ -0,0 +1,104 @@ +/* + * 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; +import org.lwjgl.opencl.api.Filter; + +import java.util.List; + +/** + * This class is a wrapper around a cl_platform_id pointer. + * + * @author Spasi + */ +public final class CLPlatform extends PointerWrapperAbstract { + + private static final CLPlatformImpl impl = (CLPlatformImpl)getClassInstance("org.lwjgl.opencl.CLPlatformImpl"); + + private Object caps; + + public CLPlatform(final long pointer) { + super(pointer); + } + + void setCapabilities(final Object caps) { + this.caps = caps; + } + + Object getCapabilities() { + return caps; + } + + // ---------------[ HELPER METHODS ]--------------- + + static Object getClassInstance(final String className) { + Object instance = null; + try { + instance = Class.forName(className).newInstance(); + } finally { + return instance; + } + } + + public static List getPlatforms() { + return getPlatforms(null); + } + + public static List getPlatforms(final Filter filter) { + return impl.getPlatforms(filter); + } + + public String getInfoString(int param_name) { + return impl.getInfoString(this, param_name); + } + + public List getDevices(final int device_type) { + return getDevices(device_type, null); + } + + public List getDevices(final int device_type, final Filter filter) { + return impl.getDevices(this, device_type, filter); + } + + /** CLPlatform helper methods implementation interface. */ + interface CLPlatformImpl { + + List getPlatforms(Filter filter); + + String getInfoString(CLPlatform platform, int param_name); + + List getDevices(CLPlatform platform, int device_type, final Filter filter); + + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLPlatformImpl.java b/src/java/org/lwjgl/opencl/CLPlatformImpl.java new file mode 100644 index 00000000..967a0b4e --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLPlatformImpl.java @@ -0,0 +1,121 @@ +/* + * 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.PointerBuffer; +import org.lwjgl.opencl.api.Filter; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import java.util.ArrayList; +import java.util.List; + +import static org.lwjgl.opencl.CL10.*; + +/** + * Implementation of CLPlatform helper methods. + * + * @author Spasi + */ +final class CLPlatformImpl implements CLPlatform.CLPlatformImpl { + + CLPlatformImpl() { + } + + static CLPlatformCapabilities getCapabilities(final CLPlatform platform) { + platform.checkNull(); + + CLPlatformCapabilities caps = (CLPlatformCapabilities)platform.getCapabilities(); + if ( caps == null ) + platform.setCapabilities(caps = new CLPlatformCapabilities(platform)); + + return caps; + } + + public List getPlatforms(final Filter filter) { + final IntBuffer numBuffer = APIUtil.getBufferInt(); + clGetPlatformIDs(null, numBuffer); + + final int num_platforms = numBuffer.get(0); + if ( num_platforms == 0 ) + return null; + + final PointerBuffer platformIDs = APIUtil.getBufferPointer(num_platforms); + clGetPlatformIDs(platformIDs, null); + + final List platforms = new ArrayList(num_platforms); + for ( int i = 0; i < num_platforms; i++ ) { + final CLPlatform platform = new CLPlatform(platformIDs.get(i)); + if ( filter == null || filter.accept(platform) ) + platforms.add(platform); + } + + return platforms.size() == 0 ? null : platforms; + } + + public String getInfoString(final CLPlatform platform, final int param_name) { + platform.checkNull(); + + final PointerBuffer bytes = APIUtil.getBufferPointer(); + clGetPlatformInfo(platform, param_name, null, bytes); + + final ByteBuffer versionBuffer = APIUtil.getBufferByte((int)bytes.get(0)); + clGetPlatformInfo(platform, param_name, versionBuffer, null); + + versionBuffer.limit((int)bytes.get(0) - 1); // Exclude null-termination + return APIUtil.getString(versionBuffer); + } + + public List getDevices(final CLPlatform platform, final int device_type, final Filter filter) { + platform.checkNull(); + + final IntBuffer numBuffer = APIUtil.getBufferInt(); + clGetDeviceIDs(platform, device_type, null, numBuffer); + + final int num_devices = numBuffer.get(0); + if ( num_devices == 0 ) + return null; + + final PointerBuffer deviceIDs = APIUtil.getBufferPointer(num_devices); + clGetDeviceIDs(platform, device_type, deviceIDs, null); + + final List devices = new ArrayList(num_devices); + for ( int i = 0; i < num_devices; i++ ) { + final CLDevice device = new CLDevice(deviceIDs.get(i)); + if ( filter == null || filter.accept(device) ) + devices.add(device); + } + + return devices.size() == 0 ? null : devices; + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLProgram.java b/src/java/org/lwjgl/opencl/CLProgram.java new file mode 100644 index 00000000..f50d4e56 --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLProgram.java @@ -0,0 +1,94 @@ +/* + * 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.PointerBuffer; + +import java.io.Serializable; + +/** + * This class is a wrapper around a cl_program pointer. + * + * @author Spasi + */ +public final class CLProgram extends CLObjectChild { + + private final CLObjectRegistry clKernels; + + CLProgram(final long pointer, final CLContext context) { + super(pointer, context); + + if ( isValid() ) { + context.getCLProgramRegistry().registerObject(this); + clKernels = new CLObjectRegistry(); + } else + clKernels = null; + } + + /** + * Returns a CLKernel associated with this program. + * + * @param id the kernel id + * + * @return the CLKernel object + */ + public CLKernel getCLKernel(final long id) { + return clKernels.getObject(id); + } + + // -------[ IMPLEMENTATION STUFF BELOW ]------- + + CLObjectRegistry getCLKernelRegistry() { return clKernels; } + + /** + * Called from clCreateKernelsInProgram to register new CLKernels. + * + * @param kernels a buffer containing CLKernel pointers. + */ + void registerCLKernels(final PointerBuffer kernels) { + for ( int i = kernels.position(); i < kernels.limit(); i++ ) { + final long pointer = kernels.get(i); + if ( pointer != 0 ) + new CLKernel(pointer, this); + } + } + + int release() { + try { + return super.release(); + } finally { + if ( !isValid() ) + getParent().getCLProgramRegistry().unregisterObject(this); + } + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLSampler.java b/src/java/org/lwjgl/opencl/CLSampler.java new file mode 100644 index 00000000..2b25d674 --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLSampler.java @@ -0,0 +1,56 @@ +/* + * 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; + +/** + * This class is a wrapper around a cl_sampler pointer. + * + * @author Spasi + */ +public final class CLSampler extends CLObjectChild { + + CLSampler(final long pointer, final CLContext context) { + super(pointer, context); + if ( isValid() ) + context.getCLSamplerRegistry().registerObject(this); + } + + int release() { + try { + return super.release(); + } finally { + if ( !isValid() ) + getParent().getCLSamplerRegistry().unregisterObject(this); + } + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CallbackUtil.java b/src/java/org/lwjgl/opencl/CallbackUtil.java new file mode 100644 index 00000000..f83798fd --- /dev/null +++ b/src/java/org/lwjgl/opencl/CallbackUtil.java @@ -0,0 +1,200 @@ +/* + * 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 java.util.HashMap; +import java.util.Map; + +/** + * Utility class that handles OpenCL API callbacks. + * + * @author Spasi + */ +final class CallbackUtil { + + private static final Map contextUserData = new HashMap(); + + private CallbackUtil() {} + + /** + * Creates a new global reference to the specified Object. + * + * @param obj the Object + * + * @return the GlobalRef memory address or 0 if the Object is null. + */ + static long createGlobalRef(final Object obj) { + return obj == null ? 0 : ncreateGlobalRef(obj); + } + + /** + * Creates a new global reference to the specified Object. + * + * @param obj the Object + * + * @return the GlobalRef memory address. + */ + private static native long ncreateGlobalRef(Object obj); + + /** + * Deletes a global reference. + * + * @param ref the GlobalRef memory address. + */ + private static native void deleteGlobalRef(long ref); + + /** + * Deletes the global reference represented by user_data if an OpenCL error occured. + * + * @param errcode the error code + * @param user_data the GlobalRef memory address + */ + static void checkCallback(final int errcode, final long user_data) { + if ( errcode != 0x0 && user_data != 0 ) + deleteGlobalRef(user_data); + } + + /* [ Context callback functionality ] + This is a little weird, so here's an explanation of what's happening for future reference: + Before making the clCreateContext call we create a global reference to the CLContextCallback object (using JNI's NewGlobalRef function). + We pass that global reference to the user_data parameter of clCreateContext. If clCreateContext returns anything but CL_SUCCESS, we + immediately destroy the global reference to avoid the memory leak. If the new context was created successfully, we associate the context + with the global reference in the contextUserData HashMap. On a future call to clReleaseContext, we clear that association and destroy the + global reference (if the reference count is 0). + */ + + /** + * Returns the memory address of the native function we pass to clCreateContext(FromType). + * + * @return the callback function address + */ + static native long getContextCallback(); + + /** + * Associates the specified CLContext with the specified global reference. If the context + * is invalid, the global reference is deleted. NO-OP if user_data is 0. + * + * @param context the CLContext to register + * @param user_data the global reference pointer + */ + static void registerCallback(final CLContext context, final long user_data) { + if ( context.getPointer() == 0 ) { + if ( user_data != 0 ) + deleteGlobalRef(user_data); + return; + } + + if ( user_data != 0 ) + contextUserData.put(context, user_data); + } + + /** + * Decrements the specified context's reference count, clears its association + * with a CLContextCallback object if it exists and deletes the corresponding + * global reference. + * + * @param context the CLContext to unregister + */ + static void unregisterCallback(final CLContext context) { + if ( context.release() > 0 ) + return; + + final Long user_data = contextUserData.remove(context); + + if ( user_data != null ) + deleteGlobalRef(user_data); + } + + /* [ Other callback functionality ] + The other callbacks are simpler. We create the GlobalRef before passing the callback, + we delete it when we receive the callback call. + */ + + /** + * Returns the memory address of the native function we pass to clSetMemObjectDestructorCallback. + * + * @return the callback function address + */ + static native long getMemObjectDestructorCallback(); + + /** + * Returns the memory address of the native function we pass to clBuildProgram. + * + * @return the callback function address + */ + static native long getBuildProgramCallback(); + + /** + * Returns the memory address of the native function we pass to clEnqueueNativeKernel. + * + * @return the callback function address + */ + static native long getNativeKernelCallback(); + + /** + * Returns the memory address of the native function we pass to clSetEventCallback. + * + * @return the callback function address + */ + static native long getEventCallback(); + + /** + * Returns the memory address of the native function we pass to clCreateContext(FromType), + * when APPLEContextLoggingUtil.SYSTEM_LOG_CALLBACK is used. + * + * @return the callback function address + * + * @see APPLEContextLoggingUtil#SYSTEM_LOG_CALLBACK + */ + static native long getLogMessageToSystemLogAPPLE(); + + /** + * Returns the memory address of the native function we pass to clCreateContext(FromType), + * when APPLEContextLoggingUtil.STD_OUT_CALLBACK is used. + * + * @return the callback function address + * + * @see APPLEContextLoggingUtil#STD_OUT_CALLBACK + */ + static native long getLogMessageToStdoutAPPLE(); + + /** + * Returns the memory address of the native function we pass to clCreateContext(FromType), + * when APPLEContextLoggingUtil.STD_ERR_CALLBACK is used. + * + * @return the callback function address + * + * @see APPLEContextLoggingUtil#STD_ERR_CALLBACK + */ + static native long getLogMessageToStderrAPPLE(); + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/OpenCLException.java b/src/java/org/lwjgl/opencl/OpenCLException.java new file mode 100644 index 00000000..fe1e9038 --- /dev/null +++ b/src/java/org/lwjgl/opencl/OpenCLException.java @@ -0,0 +1,54 @@ +/* + * 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; + +public class OpenCLException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + public OpenCLException() { + super(); + } + + public OpenCLException(final String message) { + super(message); + } + + public OpenCLException(final String message, final Throwable cause) { + super(message, cause); + } + + public OpenCLException(final Throwable cause) { + super(cause); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/Util.java b/src/java/org/lwjgl/opencl/Util.java new file mode 100644 index 00000000..848b5357 --- /dev/null +++ b/src/java/org/lwjgl/opencl/Util.java @@ -0,0 +1,76 @@ +/* + * 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 + * 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 java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Map; + +/** + * Utility methods for OpenCL + * + * @author Spasi + */ +public final class Util { + + /** Maps OpenCL error token values to their String representations. */ + private static final Map CL_ERROR_TOKENS = new HashMap(64); + + static { + APIUtil.getClassTokens(new Class[] { + CL10.class, CL11.class, + KHRGLSharing.class, KHRICD.class, + APPLEGLSharing.class, + EXTDeviceFission.class, + }, CL_ERROR_TOKENS, new APIUtil.TokenFilter() { + public boolean accept(final Field field, final int value) { + return value < 0; // Currently, all OpenCL errors have negative values. + } + }); + } + + private Util() { + } + + public static void checkCLError(final int errcode) { + if ( errcode != CL10.CL_SUCCESS ) + throwCLError(errcode); + } + + private static void throwCLError(final int errcode) { + String errname = CL_ERROR_TOKENS.get(errcode); + if ( errname == null ) + errname = "UNKNOWN"; + throw new OpenCLException("Error Code: " + errname + " (0x" + Integer.toHexString(errcode).toUpperCase() + ")"); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/api/Filter.java b/src/java/org/lwjgl/opencl/api/Filter.java new file mode 100644 index 00000000..6f7db60c --- /dev/null +++ b/src/java/org/lwjgl/opencl/api/Filter.java @@ -0,0 +1,51 @@ +/* + * 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.api; + +/** + * Simple filter interface. + * + * @author Spasi + */ +public interface Filter { + + /** + * Returns true if the specified object passes the filter. + * + * @param object the object to test + * + * @return true if the object is accepted + */ + boolean accept(T object); + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/AMDDebugOutputCallback.java b/src/java/org/lwjgl/opengl/AMDDebugOutputCallback.java index 6ff3b9d3..1146839c 100644 --- a/src/java/org/lwjgl/opengl/AMDDebugOutputCallback.java +++ b/src/java/org/lwjgl/opengl/AMDDebugOutputCallback.java @@ -31,6 +31,8 @@ */ package org.lwjgl.opengl; +import org.lwjgl.PointerWrapperAbstract; + /** * Instances of this class are needed to use the callback functionality of the AMD_debug_output extension. * A debug context must be current before creating instances of this class. Users of this class may provide @@ -39,7 +41,7 @@ package org.lwjgl.opengl; * * @author Spasi */ -public final class AMDDebugOutputCallback implements PointerWrapper { +public final class AMDDebugOutputCallback extends PointerWrapperAbstract { /** Severity levels. */ private static final int GL_DEBUG_SEVERITY_HIGH_AMD = 0x9146, @@ -56,7 +58,7 @@ public final class AMDDebugOutputCallback implements PointerWrapper { GL_DEBUG_CATEGORY_APPLICATION_AMD = 0x914F, GL_DEBUG_CATEGORY_OTHER_AMD = 0x9150; - private final long pointer; + private final Handler handler; /** * Creates an AMDDebugOutputCallback with a default callback handler. @@ -120,30 +122,31 @@ public final class AMDDebugOutputCallback implements PointerWrapper { } /** - * Creates an AMDDebugOutputCallback with the specified callback handlers. + * Creates an AMDDebugOutputCallback with the specified callback handler. * The handler's {@code handleMessage} method will be called whenever * debug output is generated by the GL. * * @param handler the callback handler */ public AMDDebugOutputCallback(final Handler handler) { + super(getFunctionPointer()); + + this.handler = handler; + } + + Handler getHandler() { + return handler; + } + + private static long getFunctionPointer() { try { - // We have to call registerHandler reflectively because we need this class to compile before we run the Generator. - // The registerHandler method depends on org.lwjgl.opengl.Context, if we touched that we would need to compile - // the whole library (which is not possible). - Class.forName("org.lwjgl.opengl.AMDDebugOutputUtil").getMethod("registerHandler", new Class[] { Handler.class }).invoke(null, new Object[] { handler }); + // Call reflectively so that we can compile this class for the Generator. + return ((Long)Class.forName("org.lwjgl.opengl.CallbackUtil").getDeclaredMethod("getDebugOutputCallbackAMD", null).invoke(null, null)).longValue(); } catch (Exception e) { throw new RuntimeException(e.getCause() != null ? e.getCause() : e); } - this.pointer = getFunctionPointer(); } - public long getPointer() { - return pointer; - } - - private static native long getFunctionPointer(); - /** Implementations of this interface can be used to receive AMD_debug_output notifications. */ public interface Handler { diff --git a/src/java/org/lwjgl/opengl/AMDDebugOutputUtil.java b/src/java/org/lwjgl/opengl/AMDDebugOutputUtil.java deleted file mode 100644 index 38f7d901..00000000 --- a/src/java/org/lwjgl/opengl/AMDDebugOutputUtil.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.lwjgl.opengl; - -import org.lwjgl.opengl.AMDDebugOutputCallback.Handler; - -import java.nio.ByteBuffer; -import java.util.Map; -import java.util.WeakHashMap; - -/** - * This class handles AMDDebugOutputCallback.Handler registration and notification. - * We could have put this in AMDDebugOutputCallback, but we need to compile it for - * the generator. Registration is done reflectively in the AMDDebugOutputCallback - * constructor. - * - * @author Spasi - */ -final class AMDDebugOutputUtil { - - private static final Map handlers = new WeakHashMap(); - - private AMDDebugOutputUtil() {} - - public static void registerHandler(final Handler handler) { - final Context ctx = Context.getCurrentContext(); - if ( ctx == null ) - throw new IllegalStateException("No context is current."); - - if ( !ctx.getContextAttribs().isDebug() ) - throw new IllegalStateException("The current context is not a debug context."); - - if ( !GLContext.getCapabilities().GL_AMD_debug_output ) - throw new IllegalStateException("AMD_debug_output is not supported."); - - handlers.put(ctx, handler); - } - - /** - * This method is called by native code. If finds the callback handler associated - * with the current Thread and calls its {@code handleMessage} method. - * - * @param id the message ID - * @param category the message category - * @param severity the message severity - * @param message the string representation of the message. - * @param userParam the user-specified data specified in glDebugMessageCallbackAMD. For the current implementation this is always null and we ignore it. - */ - private static void messageCallback(final int id, final int category, final int severity, final String message, final ByteBuffer userParam) { - synchronized ( GlobalLock.lock ) { - final Context ctx = Context.getCurrentContext(); - if ( ctx == null ) - return; - - final Handler handler = (Handler)handlers.get(ctx); - if ( handler != null ) - handler.handleMessage(id, category, severity, message); - } - } - -} diff --git a/src/java/org/lwjgl/opengl/APIUtils.java b/src/java/org/lwjgl/opengl/APIUtil.java similarity index 99% rename from src/java/org/lwjgl/opengl/APIUtils.java rename to src/java/org/lwjgl/opengl/APIUtil.java index 51ded17e..d3584317 100644 --- a/src/java/org/lwjgl/opengl/APIUtils.java +++ b/src/java/org/lwjgl/opengl/APIUtil.java @@ -38,7 +38,7 @@ import java.nio.charset.Charset; import java.nio.charset.CharsetEncoder; /** @author spasi */ -final class APIUtils { +final class APIUtil { private static final int INITIAL_BUFFER_SIZE = 256; private static final int INITIAL_LENGTHS_SIZE = 4; @@ -67,7 +67,7 @@ final class APIUtils { private static CharsetEncoder encoder = Charset.forName("US-ASCII").newEncoder(); - private APIUtils() { + private APIUtil() { } private static char[] getArray(final int size) { diff --git a/src/java/org/lwjgl/opengl/ARBDebugOutputCallback.java b/src/java/org/lwjgl/opengl/ARBDebugOutputCallback.java index 69bf1db2..2602d5b2 100644 --- a/src/java/org/lwjgl/opengl/ARBDebugOutputCallback.java +++ b/src/java/org/lwjgl/opengl/ARBDebugOutputCallback.java @@ -31,6 +31,8 @@ */ package org.lwjgl.opengl; +import org.lwjgl.PointerWrapperAbstract; + /** * Instances of this class are needed to use the callback functionality of the ARB_debug_output extension. * A debug context must be current before creating instances of this class. Users of this class may provide @@ -39,7 +41,7 @@ package org.lwjgl.opengl; * * @author Spasi */ -public final class ARBDebugOutputCallback implements PointerWrapper { +public final class ARBDebugOutputCallback extends PointerWrapperAbstract { /** Severity levels. */ private static final int @@ -65,7 +67,7 @@ public final class ARBDebugOutputCallback implements PointerWrapper { GL_DEBUG_TYPE_PERFORMANCE_ARB = 0x8250, GL_DEBUG_TYPE_OTHER_ARB = 0x8251; - private final long pointer; + private final Handler handler; /** * Creates an ARBDebugOutputCallback with a default callback handler. @@ -147,35 +149,36 @@ public final class ARBDebugOutputCallback implements PointerWrapper { } /** - * Creates an ARBDebugOutputCallback with the specified callback handlers. + * Creates an ARBDebugOutputCallback with the specified callback handler. * The handler's {@code handleMessage} method will be called whenever * debug output is generated by the GL. * * @param handler the callback handler */ public ARBDebugOutputCallback(final Handler handler) { + super(getFunctionPointer()); + + this.handler = handler; + } + + Handler getHandler() { + return handler; + } + + private static long getFunctionPointer() { try { - // We have to call registerHandler reflectively because we need this class to compile before we run the Generator. - // The registerHandler method depends on org.lwjgl.opengl.Context, if we touched that we would need to compile - // the whole library (which is not possible). - Class.forName("org.lwjgl.opengl.ARBDebugOutputUtil").getMethod("registerHandler", new Class[] { Handler.class }).invoke(null, new Object[] { handler }); + // Call reflectively so that we can compile this class for the Generator. + return ((Long)Class.forName("org.lwjgl.opengl.CallbackUtil").getDeclaredMethod("getDebugOutputCallbackARB", null).invoke(null, null)).longValue(); } catch (Exception e) { throw new RuntimeException(e.getCause() != null ? e.getCause() : e); } - this.pointer = getFunctionPointer(); } - public long getPointer() { - return pointer; - } - - private static native long getFunctionPointer(); - /** Implementations of this interface can be used to receive ARB_debug_output notifications. */ public interface Handler { /** - * This method will be called when an AMD_debug_output message is generated. + * This method will be called when an ARB_debug_output message is generated. * * @param id the message ID * @param source the message source diff --git a/src/java/org/lwjgl/opengl/ARBDebugOutputUtil.java b/src/java/org/lwjgl/opengl/ARBDebugOutputUtil.java deleted file mode 100644 index e59ac05d..00000000 --- a/src/java/org/lwjgl/opengl/ARBDebugOutputUtil.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.lwjgl.opengl; - -import org.lwjgl.opengl.ARBDebugOutputCallback.Handler; - -import java.nio.ByteBuffer; -import java.util.Map; -import java.util.WeakHashMap; - -/** - * This class handles ARBDebugOutputCallback.Handler registration and notification. - * We could have put this in ARBDebugOutputCallback, but we need to compile it for - * the generator. Registration is done reflectively in the ARBDebugOutputCallback - * constructor. - * - * @author Spasi - */ -final class ARBDebugOutputUtil { - - private static final Map handlers = new WeakHashMap(); - - private ARBDebugOutputUtil() {} - - public static void registerHandler(final Handler handler) { - final Context ctx = Context.getCurrentContext(); - if ( ctx == null ) - throw new IllegalStateException("No context is current."); - - if ( !ctx.getContextAttribs().isDebug() ) - throw new IllegalStateException("The current context is not a debug context."); - - if ( !GLContext.getCapabilities().GL_ARB_debug_output ) - throw new IllegalStateException("ARB_debug_output is not supported."); - - handlers.put(ctx, handler); - } - - /** - * This method is called by native code. If finds the callback handler associated - * with the current Thread and calls its {@code handleMessage} method. - * - * @param source the message source - * @param type the message type - * @param id the message ID - * @param severity the message severity - * @param message the string representation of the message. - * @param userParam the user-specified data specified in glDebugMessageCallbackAMD. For the current implementation this is always null and we ignore it. - */ - private static void messageCallback(final int source, final int type, final int id, final int severity, final String message, final ByteBuffer userParam) { - synchronized ( GlobalLock.lock ) { - final Context ctx = Context.getCurrentContext(); - if ( ctx == null ) - return; - - final Handler handler = (Handler)handlers.get(ctx); - if ( handler != null ) - handler.handleMessage(source, type, id, severity, message); - } - } - -} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/AWTGLCanvas.java b/src/java/org/lwjgl/opengl/AWTGLCanvas.java index 39bd9be0..d5e433d8 100644 --- a/src/java/org/lwjgl/opengl/AWTGLCanvas.java +++ b/src/java/org/lwjgl/opengl/AWTGLCanvas.java @@ -33,6 +33,7 @@ package org.lwjgl.opengl; import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; +import org.lwjgl.PointerBuffer; import org.lwjgl.Sys; import java.awt.*; @@ -258,6 +259,14 @@ public class AWTGLCanvas extends Canvas implements DrawableLWJGL, ComponentListe } } + public final void setCLSharingProperties(final PointerBuffer properties) throws LWJGLException { + synchronized ( SYNC_LOCK ) { + if ( context == null ) + throw new IllegalStateException("Canvas not yet displayable"); + context.setCLSharingProperties(properties); + } + } + /** * Override this to do initialising of the context. * It will be called once from paint(), immediately after diff --git a/src/java/org/lwjgl/opengl/AbstractDrawable.java b/src/java/org/lwjgl/opengl/AbstractDrawable.java index 18778a86..88235973 100644 --- a/src/java/org/lwjgl/opengl/AbstractDrawable.java +++ b/src/java/org/lwjgl/opengl/AbstractDrawable.java @@ -2,6 +2,7 @@ package org.lwjgl.opengl; import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; +import org.lwjgl.PointerBuffer; /** * @author Spasi @@ -73,6 +74,13 @@ abstract class AbstractDrawable implements DrawableLWJGL { } } + public void setCLSharingProperties(final PointerBuffer properties) throws LWJGLException { + synchronized ( GlobalLock.lock ) { + checkDestroyed(); + context.setCLSharingProperties(properties); + } + } + protected final void checkDestroyed() { if ( context == null ) throw new IllegalStateException("The Drawable has no context available."); diff --git a/src/java/org/lwjgl/opengl/CallbackUtil.java b/src/java/org/lwjgl/opengl/CallbackUtil.java new file mode 100644 index 00000000..728ece3e --- /dev/null +++ b/src/java/org/lwjgl/opengl/CallbackUtil.java @@ -0,0 +1,157 @@ +/* + * 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.opengl; + +import java.util.HashMap; +import java.util.Map; + +/** + * Utility class that handles OpenGL API callbacks. + * + * @author Spasi + */ +final class CallbackUtil { + + /** Context -> Long */ + private static final Map contextUserParamsARB = new HashMap(); + /** Context -> Long */ + private static final Map contextUserParamsAMD = new HashMap(); + + private CallbackUtil() {} + + /** + * Creates a new global reference to the specified Object. + * + * @param obj the Object + * + * @return the GlobalRef memory address or 0 if the Object is null. + */ + static long createGlobalRef(final Object obj) { + return obj == null ? 0 : ncreateGlobalRef(obj); + } + + /** + * Creates a new global reference to the specified Object. + * + * @param obj the Object + * + * @return the GlobalRef memory address. + */ + private static native long ncreateGlobalRef(Object obj); + + /** + * Deletes a global reference. + * + * @param ref the GlobalRef memory address. + */ + private static native void deleteGlobalRef(long ref); + + // --------- [ XXX_debug_output ] --------- + + /** + * Associates the current OpenGL context with the specified global reference. If there + * is no context current, the global reference is deleted and an exception is thrown. + * Any previous callback registrations will be cleared. + * + * @param userParam the global reference pointer + */ + private static void registerContextCallback(final long userParam, final Map contextUserData) { + Context context = Context.getCurrentContext(); + if ( context == null ) { + deleteGlobalRef(userParam); + throw new IllegalStateException("No context is current."); + } + + final Long userParam_old = (Long)contextUserData.remove(context); + if ( userParam_old != null ) + deleteGlobalRef(userParam_old.longValue()); + + if ( userParam != 0 ) + contextUserData.put(context, new Long(userParam)); + } + + /** + * Releases references to any callbacks associated with the specified GL context. + * + * @param context the Context to unregister + */ + static void unregisterCallbacks(final Context context) { + Long userParam = (Long)contextUserParamsARB.remove(context); + if ( userParam != null ) + deleteGlobalRef(userParam.longValue()); + + userParam = (Long)contextUserParamsAMD.remove(context); + if ( userParam != null ) + deleteGlobalRef(userParam.longValue()); + } + + // --------- [ ARB_debug_output ] --------- + + /** + * Returns the memory address of the native function we pass to glDebugMessageCallbackARB. + * + * @return the callback function address + */ + static native long getDebugOutputCallbackARB(); + + /** + * Associates the current OpenGL context with the specified global reference. If there + * is no context current, the global reference is deleted and an exception is thrown. + * Any previous callback registrations will be cleared. + * + * @param userParam the global reference pointer + */ + static void registerContextCallbackARB(final long userParam) { + registerContextCallback(userParam, contextUserParamsARB); + } + + // --------- [ AMD_debug_output ] --------- + + /** + * Returns the memory address of the native function we pass to glDebugMessageCallbackAMD. + * + * @return the callback function address + */ + static native long getDebugOutputCallbackAMD(); + + /** + * Associates the current OpenGL context with the specified global reference. If there + * is no context current, the global reference is deleted and an exception is thrown. + * Any previous callback registrations will be cleared. + * + * @param userParam the global reference pointer + */ + static void registerContextCallbackAMD(final long userParam) { + registerContextCallback(userParam, contextUserParamsAMD); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/Context.java b/src/java/org/lwjgl/opengl/Context.java index fa15faa1..fa9d0074 100644 --- a/src/java/org/lwjgl/opengl/Context.java +++ b/src/java/org/lwjgl/opengl/Context.java @@ -33,7 +33,9 @@ package org.lwjgl.opengl; import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; +import org.lwjgl.PointerBuffer; import org.lwjgl.Sys; +import org.lwjgl.opencl.KHRGLSharing; import java.nio.ByteBuffer; import java.nio.IntBuffer; @@ -52,10 +54,10 @@ import java.nio.IntBuffer; final class Context { /** The platform specific implementation of context methods */ - private final static ContextImplementation implementation; + private static final ContextImplementation implementation; /** The current Context */ - private final static ThreadLocal current_context_local = new ThreadLocal(); + private static final ThreadLocal current_context_local = new ThreadLocal(); /** Handle to the native GL rendering context */ private final ByteBuffer handle; @@ -206,6 +208,7 @@ final class Context { try { releaseDrawable(); implementation.destroy(peer_info, handle); + CallbackUtil.unregisterCallbacks(this); destroyed = true; thread = null; GLContext.unloadOpenGLLibrary(); @@ -256,4 +259,26 @@ final class Context { throw new OpenGLException(error); } + public synchronized void setCLSharingProperties(final PointerBuffer properties) throws LWJGLException { + final ByteBuffer peer_handle = peer_info.lockAndGetHandle(); + try { + switch ( LWJGLUtil.getPlatform() ) { + case LWJGLUtil.PLATFORM_WINDOWS: + final WindowsContextImplementation implWindows = (WindowsContextImplementation)implementation; + properties.put(KHRGLSharing.CL_GL_CONTEXT_KHR).put(implWindows.getHGLRC(handle)); + properties.put(KHRGLSharing.CL_WGL_HDC_KHR).put(implWindows.getHDC(peer_handle)); + break; + case LWJGLUtil.PLATFORM_LINUX: + final LinuxContextImplementation implLinux = (LinuxContextImplementation)implementation; + properties.put(KHRGLSharing.CL_GL_CONTEXT_KHR).put(implLinux.getGLXContext(handle)); + properties.put(KHRGLSharing.CL_GLX_DISPLAY_KHR).put(implLinux.getDisplay(peer_handle)); + break; + default: + throw new UnsupportedOperationException("CL/GL context sharing is not supposed on this platform."); + } + } finally { + peer_info.unlock(); + } + } + } \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/ContextAttribs.java b/src/java/org/lwjgl/opengl/ContextAttribs.java index 3c0ad6ec..c87e39ff 100644 --- a/src/java/org/lwjgl/opengl/ContextAttribs.java +++ b/src/java/org/lwjgl/opengl/ContextAttribs.java @@ -57,6 +57,8 @@ import java.nio.IntBuffer; public final class ContextAttribs { // Same values for GLX & WGL + private static final int CONTEXT_ES2_PROFILE_BIT_EXT = 0x00000004; + private static final int CONTEXT_ROBUST_ACCESS_BIT_ARB = 0x00000004; private static final int CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB = 0x8256; private static final int @@ -74,6 +76,7 @@ public final class ContextAttribs { private boolean profileCore; private boolean profileCompatibility; + private boolean profileES; private boolean loseContextOnReset; @@ -106,6 +109,7 @@ public final class ContextAttribs { this.profileCore = attribs.profileCore; this.profileCompatibility = attribs.profileCompatibility; + this.profileES = attribs.profileES; this.loseContextOnReset = attribs.loseContextOnReset; } @@ -138,6 +142,10 @@ public final class ContextAttribs { return profileCompatibility; } + public boolean isProfileES() { + return profileES; + } + public ContextAttribs withLayer(final int layerPlane) { if ( layerPlane < 0 ) throw new IllegalArgumentException("Invalid layer plane specified: " + layerPlane); @@ -198,6 +206,19 @@ public final class ContextAttribs { return attribs; } + public ContextAttribs withProfileES(final boolean profileES) { + if ( !(majorVersion == 2 && minorVersion == 0) ) + throw new IllegalArgumentException("The OpenGL ES profiles is only supported for OpenGL version 2.0."); + + if ( profileES == this.profileES ) + return this; + + final ContextAttribs attribs = new ContextAttribs(this); + attribs.profileES = profileES; + + return attribs; + } + /** * Returns a ContextAttribs instance with CONTEXT_RESET_NOTIFICATION_STRATEGY set * to LOSE_CONTEXT_ON_RESET if the parameter is true or to NO_RESET_NOTIFICATION @@ -254,6 +275,8 @@ public final class ContextAttribs { profileMask |= implementation.getProfileCoreBit(); else if ( profileCompatibility ) profileMask |= implementation.getProfileCompatibilityBit(); + else if ( profileES ) + profileMask |= CONTEXT_ES2_PROFILE_BIT_EXT; if ( 0 < profileMask ) attribCount++; diff --git a/src/java/org/lwjgl/opengl/Drawable.java b/src/java/org/lwjgl/opengl/Drawable.java index 84327aa2..d5fdc4b8 100644 --- a/src/java/org/lwjgl/opengl/Drawable.java +++ b/src/java/org/lwjgl/opengl/Drawable.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.LWJGLException; +import org.lwjgl.PointerBuffer; /** * The Drawable interface describes an OpenGL drawable with an associated @@ -62,4 +63,15 @@ public interface Drawable { /** Destroys the Drawable. */ void destroy(); + /** + * Sets the appropriate khr_gl_sharing properties in the target PointerBuffer, + * so that if it is used in a clCreateContext(FromType) call, the created CL + * context will be sharing objects with this Drawable's GL context. After a + * call to this method, the target buffer position will have advanced by 2 to 4 positions, + * depending on the implementation. + * + * @param properties The target properties buffer. It must have at least 4 positions remaining. + */ + void setCLSharingProperties(PointerBuffer properties) throws LWJGLException; + } diff --git a/src/java/org/lwjgl/opengl/GLSync.java b/src/java/org/lwjgl/opengl/GLSync.java index 721990e0..f9166b09 100644 --- a/src/java/org/lwjgl/opengl/GLSync.java +++ b/src/java/org/lwjgl/opengl/GLSync.java @@ -31,19 +31,17 @@ */ package org.lwjgl.opengl; +import org.lwjgl.PointerWrapperAbstract; + /** + * This class is a wrapper around a GLsync pointer. + * * @author spasi */ -public final class GLSync implements PointerWrapper { - - private final long sync; +public final class GLSync extends PointerWrapperAbstract { GLSync(final long sync) { - this.sync = sync; - } - - public long getPointer() { - return sync; + super(sync); } } \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/LinuxContextImplementation.java b/src/java/org/lwjgl/opengl/LinuxContextImplementation.java index 48feedb8..f64c9723 100644 --- a/src/java/org/lwjgl/opengl/LinuxContextImplementation.java +++ b/src/java/org/lwjgl/opengl/LinuxContextImplementation.java @@ -59,6 +59,10 @@ final class LinuxContextImplementation implements ContextImplementation { private static native ByteBuffer nCreate(ByteBuffer peer_handle, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException; + native long getGLXContext(ByteBuffer context_handle); + + native long getDisplay(ByteBuffer peer_info_handle); + public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException { } diff --git a/src/java/org/lwjgl/opengl/WindowsContextImplementation.java b/src/java/org/lwjgl/opengl/WindowsContextImplementation.java index c0169667..a835506b 100644 --- a/src/java/org/lwjgl/opengl/WindowsContextImplementation.java +++ b/src/java/org/lwjgl/opengl/WindowsContextImplementation.java @@ -55,6 +55,10 @@ final class WindowsContextImplementation implements ContextImplementation { private static native ByteBuffer nCreate(ByteBuffer peer_handle, IntBuffer attribs_handle, ByteBuffer shared_context_handle) throws LWJGLException; + native long getHGLRC(ByteBuffer context_handle); + + native long getHDC(ByteBuffer peer_info_handle); + public void swapBuffers() throws LWJGLException { Context current_context = Context.getCurrentContext(); if ( current_context == null ) diff --git a/src/java/org/lwjgl/test/opencl/HelloOpenCL.java b/src/java/org/lwjgl/test/opencl/HelloOpenCL.java new file mode 100644 index 00000000..76c5725c --- /dev/null +++ b/src/java/org/lwjgl/test/opencl/HelloOpenCL.java @@ -0,0 +1,185 @@ +/* + * 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.test.opencl; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.PointerBuffer; +import org.lwjgl.opencl.*; + +import java.nio.ByteBuffer; +import java.util.List; + +import static org.lwjgl.opencl.CL10.*; +import static org.lwjgl.opencl.CL11.*; + +/** Basic OpenCL test. */ +public class HelloOpenCL { + + public HelloOpenCL() { + } + + protected void execute() { + try { + CL.create(); + + final List platforms = CLPlatform.getPlatforms(); + for ( CLPlatform platform : platforms ) { + System.out.println("\n-------------------------"); + System.out.println("NEW PLATFORM: " + platform.getPointer()); + System.out.println(CLCapabilities.getPlatformCapabilities(platform)); + System.out.println("-------------------------"); + printPlatformInfo(platform, "CL_PLATFORM_PROFILE", CL_PLATFORM_PROFILE); + printPlatformInfo(platform, "CL_PLATFORM_VERSION", CL_PLATFORM_VERSION); + printPlatformInfo(platform, "CL_PLATFORM_NAME", CL_PLATFORM_NAME); + printPlatformInfo(platform, "CL_PLATFORM_VENDOR", CL_PLATFORM_VENDOR); + System.out.println(""); + + final PointerBuffer ctxProps = BufferUtils.createPointerBuffer(3); + ctxProps.put(CL_CONTEXT_PLATFORM).put(platform.getPointer()).put(0).flip(); + + final List devices = platform.getDevices(CL_DEVICE_TYPE_ALL); + for ( CLDevice device : devices ) { + System.out.println("\n\tNEW DEVICE: " + device.getPointer()); + System.out.println(CLCapabilities.getDeviceCapabilities(device)); + System.out.println("\t-------------------------"); + + System.out.println("\tCL_DEVICE_TYPE = " + device.getInfoInt(CL_DEVICE_TYPE)); + System.out.println("\tCL_DEVICE_VENDOR_ID = " + device.getInfoInt(CL_DEVICE_VENDOR_ID)); + System.out.println("\tCL_DEVICE_MAX_COMPUTE_UNITS = " + device.getInfoInt(CL_DEVICE_MAX_COMPUTE_UNITS)); + System.out.println("\tCL_DEVICE_MAX_WORK_ITEM_DIMENSIONS = " + device.getInfoInt(CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS)); + //CL10.clGetDeviceInfo(device, CL10.CL_DEVICE_MAX_WORK_ITEM_SIZES, info, size_ret); + //System.out.println("\tCL_DEVICE_MAX_WORK_ITEM_SIZES = " + info.getInt(0)); + System.out.println("\tCL_DEVICE_MAX_WORK_GROUP_SIZE = " + device.getInfoSize(CL_DEVICE_MAX_WORK_GROUP_SIZE)); + System.out.println("\tCL_DEVICE_MAX_CLOCK_FREQUENCY = " + device.getInfoInt(CL_DEVICE_MAX_CLOCK_FREQUENCY)); + System.out.println("\tCL_DEVICE_ADDRESS_BITS = " + device.getInfoInt(CL_DEVICE_ADDRESS_BITS)); + System.out.println("\tCL_DEVICE_AVAILABLE = " + device.getInfoBoolean(CL_DEVICE_AVAILABLE)); + System.out.println("\tCL_DEVICE_COMPILER_AVAILABLE = " + device.getInfoBoolean(CL_DEVICE_COMPILER_AVAILABLE)); + + printDeviceInfo(device, "CL_DEVICE_NAME", CL_DEVICE_NAME); + printDeviceInfo(device, "CL_DEVICE_VENDOR", CL_DEVICE_VENDOR); + printDeviceInfo(device, "CL_DRIVER_VERSION", CL_DRIVER_VERSION); + printDeviceInfo(device, "CL_DEVICE_PROFILE", CL_DEVICE_PROFILE); + printDeviceInfo(device, "CL_DEVICE_VERSION", CL_DEVICE_VERSION); + printDeviceInfo(device, "CL_DEVICE_OPENCL_C_VERSION", CL_DEVICE_OPENCL_C_VERSION); + + CLContext context = clCreateContext(ctxProps, device, new CLContextCallback() { + protected void handleMessage(final String errinfo, final ByteBuffer private_info) { + System.out.println("IN CLContextCallback :: " + errinfo); + } + }, null); + + CLMem buffer = clCreateBuffer(context, CL_MEM_READ_ONLY, 128, null); + + clSetMemObjectDestructorCallback(buffer, new CLMemObjectDestructorCallback() { + protected void handleMessage(final long memobj) { + System.out.println("FIRST Buffer destructed: " + memobj); + } + }); + + clSetMemObjectDestructorCallback(buffer, new CLMemObjectDestructorCallback() { + protected void handleMessage(final long memobj) { + System.out.println("SECOND Buffer destructed: " + memobj); + } + }); + + ByteBuffer bufferCreateInfo = BufferUtils.createByteBuffer(2 * PointerBuffer.getPointerSize()); + PointerBuffer.put(bufferCreateInfo, 0); + PointerBuffer.put(bufferCreateInfo, 64); + bufferCreateInfo.flip(); + CLMem subbuffer = clCreateSubBuffer(buffer, CL10.CL_MEM_READ_ONLY, CL11.CL_BUFFER_CREATE_TYPE_REGION, bufferCreateInfo, null); + + clSetMemObjectDestructorCallback(subbuffer, new CLMemObjectDestructorCallback() { + protected void handleMessage(final long memobj) { + System.out.println("Sub Buffer destructed: " + memobj); + } + }); + + clRetainMemObject(buffer); + + final long exec_caps = device.getInfoLong(CL_DEVICE_EXECUTION_CAPABILITIES); + if ( (exec_caps & CL_EXEC_NATIVE_KERNEL) == CL_EXEC_NATIVE_KERNEL ) { + System.out.println("-TRYING TO EXEC NATIVE KERNEL-"); + final CLCommandQueue queue = clCreateCommandQueue(context, device, 0, null); + + 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); + } + } + } + } + }, new CLMem[] { buffer }, new long[] { 128 }, null, null); + + clFinish(queue); + } + + clReleaseMemObject(buffer); + clReleaseContext(context); + } + } + } catch (LWJGLException le) { + die("Init", le.getMessage()); + } + + CL.destroy(); + } + + private static void printPlatformInfo(final CLPlatform platform, final String param_name, final int param) { + System.out.println("\t" + param_name + " = " + platform.getInfoString(param)); + } + + private static void printDeviceInfo(final CLDevice device, final String param_name, final int param) { + System.out.println("\t" + param_name + " = " + device.getInfoString(param)); + } + + private static void die(String kind, String description) { + System.out.println(kind + " error " + description + " occured"); + } + + /** + * main entry point + * + * @param args String array containing arguments + */ + public static void main(String[] args) { + new HelloOpenCL().execute(); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/test/opencl/gl/DemoFractal.java b/src/java/org/lwjgl/test/opencl/gl/DemoFractal.java new file mode 100644 index 00000000..1bc646fd --- /dev/null +++ b/src/java/org/lwjgl/test/opencl/gl/DemoFractal.java @@ -0,0 +1,675 @@ +/* + * 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.test.opencl.gl; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.PointerBuffer; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opencl.*; +import org.lwjgl.opencl.api.Filter; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; +import org.lwjgl.opengl.Drawable; +import org.lwjgl.util.Color; +import org.lwjgl.util.ReadableColor; + +import java.io.*; +import java.nio.IntBuffer; +import java.util.List; + +import static java.lang.Math.*; +import static org.lwjgl.opencl.CL10.*; +import static org.lwjgl.opencl.CL10GL.*; +import static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.opengl.GL12.*; +import static org.lwjgl.opengl.GL15.*; +import static org.lwjgl.opengl.GL21.*; + +/* + THIS DEMO USES CODE PORTED FROM JogAmp.org + Original code: http://github.com/mbien/jocl-demos + Original author: Michael Bien + + ___ ___ ___ + / /\ / /\ ___ / /\ http://jocl.jogamp.org/ + / /:/ / /::\ /__/\ / /::\ a http://jogamp.org/ project. + /__/::\ / /:/\:\ \ \:\ / /:/\:\ + \__\/\:\ / /:/~/::\ \ \:\ / /:/~/::\ + \ \:\ /__/:/ /:/\:\ ___ \__\:\/__/:/ /:/\:\ + \__\:\\ \:\/:/__\//__/\ | |:|\ \:\/:/__\/ + / /:/ \ \::/ \ \:\| |:| \ \::/ + /__/:/ \ \:\ \ \:\__|:| \ \:\ + \__\/ \ \:\ \__\::::/ \ \:\ + \__\/ ~~~~ \__\/ + ___ ___ ___ ___ ___ + / /\ / /\ / /\ /__/\ / /\ + / /::\ / /::\ / /:/_ \ \:\ / /:/ + / /:/\:\ / /:/\:\ / /:/ /\ \ \:\ / /:/ ___ ___ + / /:/ \:\ / /:/~/:// /:/ /:/_ _____\__\:\ / /:/ ___ /__/\ / /\ + /__/:/ \__\:\/__/:/ /://__/:/ /:/ /\/__/::::::::\/__/:/ / /\\ \:\ / /:/ + \ \:\ / /:/\ \:\/:/ \ \:\/:/ /:/\ \:\~~\~~\/\ \:\ / /:/ \ \:\ /:/ + \ \:\ /:/ \ \::/ \ \::/ /:/ \ \:\ ~~~ \ \:\ /:/ \ \:\/:/ + \ \:\/:/ \ \:\ \ \:\/:/ \ \:\ \ \:\/:/ \ \::/ + \ \::/ \ \:\ \ \::/ \ \:\ \ \::/ \__\/ + \__\/ \__\/ \__\/ \__\/ \__\/ + + _____ ___ ___ ___ ___ + / /::\ / /\ /__/\ / /\ / /\ + / /:/\:\ / /:/_ | |::\ / /::\ / /:/_ + / /:/ \:\ / /:/ /\ | |:|:\ / /:/\:\ / /:/ /\ + /__/:/ \__\:| / /:/ /:/_ __|__|:|\:\ / /:/ \:\ / /:/ /::\ + \ \:\ / /:/ /__/:/ /:/ /\ /__/::::| \:\ /__/:/ \__\:\ /__/:/ /:/\:\ + \ \:\ /:/ \ \:\/:/ /:/ \ \:\~~\__\/ \ \:\ / /:/ \ \:\/:/~/:/ + \ \:\/:/ \ \::/ /:/ \ \:\ \ \:\ /:/ \ \::/ /:/ + \ \::/ \ \:\/:/ \ \:\ \ \:\/:/ \__\/ /:/ + \__\/ \ \::/ \ \:\ \ \::/ /__/:/ + \__\/ \__\/ \__\/ \__\/ +*/ + +/** + * Computes the Mandelbrot set with OpenCL using multiple GPUs and renders the result with OpenGL. + * A shared PBO is used as storage for the fractal image.
+ * http://en.wikipedia.org/wiki/Mandelbrot_set + *

+ * controls:
+ * keys 1-9 control parallelism level
+ * space enables/disables slice seperator
+ * 'd' toggles between 32/64bit floatingpoint precision
+ * mouse/mousewheel to drag and zoom
+ * 'Home' to reset the viewport
+ *

+ * + * @author Michael Bien, Spasi + */ +public class DemoFractal { + + // max number of used GPUs + private static final int MAX_PARALLELISM_LEVEL = 8; + + // max per pixel iterations to compute the fractal + private static final int MAX_ITERATIONS = 500; + + private CLContext clContext; + private CLCommandQueue[] queues; + private CLKernel[] kernels; + private CLProgram[] programs; + + private CLMem[] pboBuffers; + private IntBuffer pboIDs; + + private CLMem[] colorMap; + private IntBuffer[] colorMapBuffer; + + private final PointerBuffer kernel2DGlobalWorkSize; + + private int width = 0; + private int height = 0; + + private double minX = -2f; + private double minY = -1.2f; + private double maxX = 0.6f; + private double maxY = 1.3f; + + private boolean dragging; + private double dragX; + private double dragY; + private double dragMinX; + private double dragMinY; + private double dragMaxX; + private double dragMaxY; + + private int mouseX; + private int mouseY; + + private int slices; + + private boolean drawSeparator; + private boolean doublePrecision = true; + private boolean buffersInitialized; + private boolean rebuild; + + private boolean run = true; + + public DemoFractal(int width, int height) { + kernel2DGlobalWorkSize = BufferUtils.createPointerBuffer(2); + + this.width = width; + this.height = height; + } + + private void run() { + long startTime = System.currentTimeMillis() + 5000; + long fps = 0; + + while ( run ) { + if ( !Display.isVisible() ) + Thread.yield(); + + handleIO(); + display(); + + Display.update(); + if ( Display.isCloseRequested() ) + break; + + if ( startTime > System.currentTimeMillis() ) { + fps++; + } else { + long timeUsed = 5000 + (startTime - System.currentTimeMillis()); + startTime = System.currentTimeMillis() + 5000; + System.out.println(fps + " frames in 5 seconds = " + (fps / (timeUsed / 1000f))); + fps = 0; + } + } + + CL.destroy(); + Display.destroy(); + } + + private void handleIO() { + if ( Keyboard.getNumKeyboardEvents() != 0 ) { + while ( Keyboard.next() ) { + if ( Keyboard.getEventKeyState() ) + continue; + + final int key = Keyboard.getEventKey(); + + if ( Keyboard.KEY_1 <= key && key <= Keyboard.KEY_8 ) { + int number = key - Keyboard.KEY_1 + 1; + slices = min(number, min(queues.length, MAX_PARALLELISM_LEVEL)); + System.out.println("NEW PARALLELISM LEVEL: " + slices); + buffersInitialized = false; + } else { + switch ( Keyboard.getEventKey() ) { + case Keyboard.KEY_SPACE: + drawSeparator = !drawSeparator; + System.out.println("SEPARATOR DRAWING IS NOW: " + (drawSeparator ? "ON" : "OFF")); + break; + case Keyboard.KEY_D: + doublePrecision = !doublePrecision; + System.out.println("DOUBLE PRECISION IS NOW: " + (doublePrecision ? "ON" : "OFF")); + rebuild = true; + break; + case Keyboard.KEY_HOME: + minX = -2f; + minY = -1.2f; + maxX = 0.6f; + maxY = 1.3f; + break; + case Keyboard.KEY_ESCAPE: + run = false; + break; + } + } + } + } + + while ( Mouse.next() ) { + final int eventBtn = Mouse.getEventButton(); + + final int x = Mouse.getX(); + final int y = Mouse.getY(); + + if ( Mouse.isButtonDown(0) && (x != mouseX || y != mouseY) ) { + if ( !dragging ) { + dragging = true; + + dragX = mouseX; + dragY = mouseY; + + dragMinX = minX; + dragMinY = minY; + dragMaxX = maxX; + dragMaxY = maxY; + } + + double offsetX = (x - dragX) * (maxX - minX) / width; + double offsetY = (y - dragY) * (maxY - minY) / height; + + minX = dragMinX - offsetX; + minY = dragMinY - offsetY; + + maxX = dragMaxX - offsetX; + maxY = dragMaxY - offsetY; + } else { + if ( dragging ) + dragging = false; + + if ( eventBtn == -1 ) { + final int dwheel = Mouse.getEventDWheel(); + if ( dwheel != 0 ) { + double scale = dwheel > 0 ? 0.05 : -0.05; + + double deltaX = scale * (maxX - minX); + double deltaY = scale * (maxY - minY); + + // offset for "zoom to cursor" + double offsetX = (x / (double)width - 0.5) * deltaX * 2.0; + double offsetY = (y / (double)height - 0.5) * deltaY * 2.0; + + minX += deltaX + offsetX; + minY += deltaY - offsetY; + + maxX += -deltaX + offsetX; + maxY += -deltaY - offsetY; + } + } + } + + mouseX = x; + mouseY = y; + } + } + + public void init() { + try { + Display.setDisplayMode(new DisplayMode(width, height)); + Display.setTitle("OpenCL Fractal Demo"); + Display.create(); + CL.create(); + } catch (LWJGLException e) { + throw new RuntimeException(e); + } + + try { + initCL(Display.getDrawable()); + } catch (Exception e) { + if ( clContext != null ) + clReleaseContext(clContext); + Display.destroy(); + throw new RuntimeException(e); + } + + Display.setSwapInterval(0); + glDisable(GL_DEPTH_TEST); + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + + initView(Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight()); + + initPBO(); + glFinish(); + + setKernelConstants(); + } + + private void initCL(Drawable drawable) throws Exception { + // Find a platform + List platforms = CLPlatform.getPlatforms(); + if ( platforms == null ) + throw new RuntimeException("No OpenCL platforms found."); + + final CLPlatform platform = platforms.get(0); // just grab the first one + + // Find devices with GL sharing support + final Filter glSharingFilter = new Filter() { + public boolean accept(final CLDevice device) { + final CLDeviceCapabilities caps = CLCapabilities.getDeviceCapabilities(device); + return caps.CL_KHR_gl_sharing; + } + }; + List devices = platform.getDevices(CL_DEVICE_TYPE_GPU, glSharingFilter); + if ( devices == null ) { + devices = platform.getDevices(CL_DEVICE_TYPE_CPU, glSharingFilter); + if ( devices == null ) + throw new RuntimeException("No OpenCL devices found."); + } + + // Create the context + final PointerBuffer deviceIDs = BufferUtils.createPointerBuffer(devices.size()); + for ( CLDevice device : devices ) + deviceIDs.put(device); + deviceIDs.flip(); + + final PointerBuffer contextProps = BufferUtils.createPointerBuffer(2 + 4 + 1); + contextProps.put(CL_CONTEXT_PLATFORM).put(platform); + + drawable.setCLSharingProperties(contextProps); // Enable GL sharing + + contextProps.put(0); + contextProps.flip(); + clContext = clCreateContext(contextProps, deviceIDs, null, null); + + slices = min(devices.size(), MAX_PARALLELISM_LEVEL); + + // create command queues for every GPU, setup colormap and init kernels + queues = new CLCommandQueue[slices]; + kernels = new CLKernel[slices]; + colorMap = new CLMem[slices]; + colorMapBuffer = new IntBuffer[slices]; + + for ( int i = 0; i < slices; i++ ) { + colorMapBuffer[i] = BufferUtils.createIntBuffer(32 * 2); + colorMap[i] = clCreateBuffer(clContext, CL_MEM_READ_ONLY, colorMapBuffer[i].capacity() * 4, null); + colorMap[i].checkNull(); + + initColorMap(colorMapBuffer[i], 32, Color.BLUE, Color.GREEN, Color.RED); + + // create command queue and upload color map buffer on each used device + queues[i] = clCreateCommandQueue(clContext, devices.get(i), CL_QUEUE_PROFILING_ENABLE, null); + queues[i].checkNull(); + clEnqueueWriteBuffer(queues[i], colorMap[i], CL_TRUE, 0, colorMapBuffer[i], null, null); // blocking upload + + } + + // check if we have 64bit FP support on all devices + // if yes we can use only one program for all devices + one kernel per device. + // if not we will have to create (at least) one program for 32 and one for 64bit devices. + // since there are different vendor extensions for double FP we use one program per device. + // (OpenCL spec is not very clear about this usecases) + boolean all64bit = true; + for ( CLDevice device : devices ) { + if ( !isDoubleFPAvailable(device) ) { + all64bit = false; + break; + } + } + + // load program(s) + programs = new CLProgram[all64bit ? 1 : slices]; + + buildPrograms(); + } + + private void createPrograms() throws IOException { + final String source = getProgramSource("Mandelbrot.cl"); + for ( int i = 0; i < programs.length; i++ ) + programs[i] = clCreateProgramWithSource(clContext, source, null); + } + + private String getProgramSource(final String file) throws IOException { + InputStream source = getClass().getResourceAsStream(file); + if ( source == null ) // dev-mode + source = new FileInputStream("src/java/org/lwjgl/test/opencl/gl/" + file); + final BufferedReader reader = new BufferedReader(new InputStreamReader(source)); + + final StringBuilder sb = new StringBuilder(); + String line; + try { + while ( (line = reader.readLine()) != null ) + sb.append(line).append("\n"); + } finally { + source.close(); + } + + return sb.toString(); + } + + private static void initColorMap(IntBuffer colorMap, int stepSize, ReadableColor... colors) { + for ( int n = 0; n < colors.length - 1; n++ ) { + ReadableColor color = colors[n]; + int r0 = color.getRed(); + int g0 = color.getGreen(); + int b0 = color.getBlue(); + + color = colors[n + 1]; + int r1 = color.getRed(); + int g1 = color.getGreen(); + int b1 = color.getBlue(); + + int deltaR = r1 - r0; + int deltaG = g1 - g0; + int deltaB = b1 - b0; + + for ( int step = 0; step < stepSize; step++ ) { + float alpha = (float)step / (stepSize - 1); + int r = (int)(r0 + alpha * deltaR); + int g = (int)(g0 + alpha * deltaG); + int b = (int)(b0 + alpha * deltaB); + colorMap.put((r << 16) | (g << 8) | (b << 0)); + } + } + colorMap.rewind(); + } + + private static void initView(int width, int height) { + glViewport(0, 0, width, height); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0.0, width, 0.0, height, 0.0, 1.0); + } + + private void initPBO() { + if ( pboBuffers == null ) { + pboBuffers = new CLMem[slices]; + pboIDs = BufferUtils.createIntBuffer(slices); + } else { + for ( CLMem pboBuffer : pboBuffers ) + clReleaseMemObject(pboBuffer); + glDeleteBuffers(pboIDs); + } + + glGenBuffers(pboIDs); + + // setup one empty PBO per slice + for ( int i = 0; i < slices; i++ ) { + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pboIDs.get(i)); + glBufferData(GL_PIXEL_UNPACK_BUFFER, width * height * 4 / slices, GL_STREAM_DRAW); + + pboBuffers[i] = clCreateFromGLBuffer(clContext, CL_MEM_WRITE_ONLY, pboIDs.get(i), null); + } + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); + + buffersInitialized = true; + } + + private void buildPrograms() { + /* + * workaround: The driver keeps using the old binaries for some reason. + * to solve this we simple create a new program and release the old. + * however rebuilding programs should be possible -> remove when drivers are fixed. + * (again: the spec is not very clear about this kind of usages) + */ + if ( programs[0] != null ) { + for ( CLProgram program : programs ) + clReleaseProgram(program); + } + + try { + createPrograms(); + } catch (IOException e) { + throw new RuntimeException(e); + } + + // disable 64bit floating point math if not available + for ( int i = 0; i < programs.length; i++ ) { + final CLDevice device = queues[i].getCLDevice(); + + final StringBuilder options = new StringBuilder("-cl-fast-relaxed-math"); + final CLDeviceCapabilities caps = CLCapabilities.getDeviceCapabilities(device); + if ( doublePrecision && isDoubleFPAvailable(device) ) { + //cl_khr_fp64 + options.append(" -D DOUBLE_FP"); + + //amd's verson of double precision floating point math + if ( !caps.CL_KHR_fp64 && caps.CL_AMD_fp64 ) + options.append(" -D AMD_FP"); + } + + System.out.println("COMPILER OPTIONS: " + options); + + clBuildProgram(programs[i], device, options, null); + } + + rebuild = false; + + for ( int i = 0; i < kernels.length; i++ ) { + // init kernel with constants + kernels[i] = clCreateKernel(programs[min(i, programs.length)], "mandelbrot", null); + } + + } + + // init kernels with constants + + private void setKernelConstants() { + for ( int i = 0; i < slices; i++ ) { + kernels[i] + .setArg(6, pboBuffers[i]) + .setArg(7, colorMap[i]) + .setArg(8, colorMapBuffer[i].capacity()) + .setArg(9, MAX_ITERATIONS); + } + } + + // rendering cycle + + public void display() { + // make sure GL does not use our objects before we start computeing + glFinish(); + + if ( !buffersInitialized ) { + initPBO(); + setKernelConstants(); + } + + if ( rebuild ) { + buildPrograms(); + setKernelConstants(); + } + compute(doublePrecision); + + render(); + } + + // OpenCL + + private void compute(final boolean is64bit) { + int sliceWidth = (int)(width / (float)slices); + double rangeX = (maxX - minX) / slices; + double rangeY = (maxY - minY); + + kernel2DGlobalWorkSize.put(0, sliceWidth).put(1, height); + + // start computation + for ( int i = 0; i < slices; i++ ) { + kernels[i].setArg(0, sliceWidth).setArg(1, height); + if ( !is64bit || !isDoubleFPAvailable(queues[i].getCLDevice()) ) { + kernels[i] + .setArg(2, (float)(minX + rangeX * i)).setArg(3, (float)minY) + .setArg(4, (float)rangeX).setArg(5, (float)rangeY); + } else { + kernels[i] + .setArg(2, minX + rangeX * i).setArg(3, minY) + .setArg(4, rangeX).setArg(5, rangeY); + } + + // aquire GL objects, and enqueue a kernel with a probe from the list + clEnqueueAcquireGLObjects(queues[i], pboBuffers[i], null, null); + + clEnqueueNDRangeKernel(queues[i], kernels[i], 2, + null, + kernel2DGlobalWorkSize, + null, + null, null); + + clEnqueueReleaseGLObjects(queues[i], pboBuffers[i], null, null); + } + + // block until done (important: finish before doing further gl work) + for ( int i = 0; i < slices; i++ ) { + clFinish(queues[i]); + } + + } + + // OpenGL + + private void render() { + glClear(GL_COLOR_BUFFER_BIT); + + //draw slices + int sliceWidth = width / slices; + + for ( int i = 0; i < slices; i++ ) { + int seperatorOffset = drawSeparator ? i : 0; + + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pboIDs.get(i)); + glRasterPos2i(sliceWidth * i + seperatorOffset, 0); + + glDrawPixels(sliceWidth, height, GL_BGRA, GL_UNSIGNED_BYTE, 0); + + } + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); + + //draw info text + /* + textRenderer.beginRendering(width, height, false); + + textRenderer.draw("device/time/precision", 10, height - 15); + + for ( int i = 0; i < slices; i++ ) { + CLDevice device = queues[i].getDevice(); + boolean doubleFP = doublePrecision && isDoubleFPAvailable(device); + CLEvent event = probes.getEvent(i); + long start = event.getProfilingInfo(START); + long end = event.getProfilingInfo(END); + textRenderer.draw(device.getType().toString() + i + " " + + (int)((end - start) / 1000000.0f) + "ms @" + + (doubleFP ? "64bit" : "32bit"), 10, height - (20 + 16 * (slices - i))); + } + + textRenderer.endRendering(); + */ + } + + public void reshape(int x, int y, int width, int height) { + if ( this.width == width && this.height == height ) + return; + + this.width = width; + this.height = height; + + initPBO(); + setKernelConstants(); + + initView(width, height); + + } + + private static boolean isDoubleFPAvailable(CLDevice device) { + final CLDeviceCapabilities caps = CLCapabilities.getDeviceCapabilities(device); + return caps.CL_KHR_fp64 || caps.CL_AMD_fp64; + } + + public static void main(String args[]) { + DemoFractal demo = new DemoFractal(512, 512); + demo.init(); + demo.run(); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/test/opencl/gl/Mandelbrot.cl b/src/java/org/lwjgl/test/opencl/gl/Mandelbrot.cl new file mode 100644 index 00000000..2fc959c2 --- /dev/null +++ b/src/java/org/lwjgl/test/opencl/gl/Mandelbrot.cl @@ -0,0 +1,55 @@ +#ifdef DOUBLE_FP + #ifdef AMD_FP + #pragma OPENCL EXTENSION cl_amd_fp64 : enable + #else + #pragma OPENCL EXTENSION cl_khr_fp64 : enable + #endif + typedef double varfloat; +#else + typedef float varfloat; +#endif + +/** + * For a description of this algorithm please refer to + * http://en.wikipedia.org/wiki/Mandelbrot_set + * @author Michael Bien + */ +kernel void mandelbrot( + const int width, const int height, + const varfloat x0, const varfloat y0, + const varfloat rangeX, const varfloat rangeY, + global uint *output, global uint *colorMap, + const int colorMapSize, const int maxIterations) { + + unsigned int ix = get_global_id(0); + unsigned int iy = get_global_id(1); + + varfloat r = x0 + ix * rangeX / width; + varfloat i = y0 + iy * rangeY / height; + + varfloat x = 0; + varfloat y = 0; + + varfloat magnitudeSquared = 0; + int iteration = 0; + + while (magnitudeSquared < 4 && iteration < maxIterations) { + varfloat x2 = x*x; + varfloat y2 = y*y; + y = 2 * x * y + i; + x = x2 - y2 + r; + magnitudeSquared = x2+y2; + iteration++; + } + + if (iteration == maxIterations) { + output[iy * width + ix] = 0; + }else { + varfloat alpha = (varfloat)iteration / maxIterations; + int colorIndex = (int)(alpha * colorMapSize); + output[iy * width + ix] = colorMap[colorIndex]; + // monochrom + // output[iy * width + ix] = 255*iteration/maxIterations; + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/test/opengl/VersionTest.java b/src/java/org/lwjgl/test/opengl/VersionTest.java index 44d94437..87d3de40 100644 --- a/src/java/org/lwjgl/test/opengl/VersionTest.java +++ b/src/java/org/lwjgl/test/opengl/VersionTest.java @@ -81,6 +81,8 @@ public final class VersionTest { ca = ca.withProfileCore(true); else if ( "compatibility".equalsIgnoreCase(args[i]) ) ca = ca.withProfileCompatibility(true); + else if ( "es".equalsIgnoreCase(args[i]) ) + ca = ca.withProfileES(true); else argsError("Unknown argument: \'" + args[i] + "\'"); } @@ -236,6 +238,7 @@ public final class VersionTest { System.out.println("majorVersion\t- Minor OpenGL version."); System.out.println("core\t- Sets the Core Profile bit (optional, requires 3.2+)."); System.out.println("compatibility\t- Sets the Compatibility Profile bit (optional, requires 3.2+)."); + System.out.println("ws\t- Sets the OpenGL ES Profile bit (optional, requires 2.0)."); System.out.println("layer\t- Layer plane (optional)."); System.out.println("debug\t- Enables debug mode (optional)."); System.out.println("fc\t- Enables forward compatibility mode (optional, requires 3.0+)."); diff --git a/src/java/org/lwjgl/util/generator/Alternate.java b/src/java/org/lwjgl/util/generator/Alternate.java index 67fe5188..c1374154 100644 --- a/src/java/org/lwjgl/util/generator/Alternate.java +++ b/src/java/org/lwjgl/util/generator/Alternate.java @@ -49,6 +49,9 @@ public @interface Alternate { /** If true, an alternate Java->native call will be created. Useful when the alternate implementation uses different types. */ boolean nativeAlt() default false; + /** Applicable when nativeAlt is true. If true, no extra native call will be generated. Useful when there's another nativeAlt already defined. */ + boolean skipNative() default false; + /** If true, the alternate method's name will be used for the Java call. */ boolean javaAlt() default false; } \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/AutoSize.java b/src/java/org/lwjgl/util/generator/AutoSize.java index 90318dcb..319bef53 100644 --- a/src/java/org/lwjgl/util/generator/AutoSize.java +++ b/src/java/org/lwjgl/util/generator/AutoSize.java @@ -45,9 +45,10 @@ import java.lang.annotation.Target; import java.lang.annotation.ElementType; @Auto -@Target(ElementType.PARAMETER) +@Target({ElementType.METHOD,ElementType.PARAMETER}) public @interface AutoSize { String value(); // The name of the Buffer parameter String expression() default ""; // This value is added after the argument 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. } diff --git a/src/java/org/lwjgl/util/generator/Check.java b/src/java/org/lwjgl/util/generator/Check.java index 759ec4a1..6421bbc1 100644 --- a/src/java/org/lwjgl/util/generator/Check.java +++ b/src/java/org/lwjgl/util/generator/Check.java @@ -41,7 +41,7 @@ package org.lwjgl.util.generator; import java.lang.annotation.Target; import java.lang.annotation.ElementType; -@Target(ElementType.PARAMETER) +@Target({ElementType.PARAMETER, ElementType.METHOD}) public @interface Check { String value() default ""; boolean canBeNull() default false; diff --git a/src/java/org/lwjgl/util/generator/Code.java b/src/java/org/lwjgl/util/generator/Code.java index 15091415..84cd2ffc 100644 --- a/src/java/org/lwjgl/util/generator/Code.java +++ b/src/java/org/lwjgl/util/generator/Code.java @@ -38,10 +38,22 @@ package org.lwjgl.util.generator; * $Id$ */ -import java.lang.annotation.Target; import java.lang.annotation.ElementType; +import java.lang.annotation.Target; @Target(ElementType.METHOD) public @interface Code { - String value(); + + String value() default ""; // Java, before everything + + boolean tryBlock() default false; // Add a try/finally block around the native call and return statement + + String javaBeforeNative() default ""; // Before the native call + String javaAfterNative() default ""; // After the native call + String javaFinally() default ""; // In the finally block + + String nativeAfterVars() default ""; // After variable declaration + String nativeBeforeCall() default ""; // Before the API call + String nativeAfterCall() default ""; // After the API call + } diff --git a/src/java/org/lwjgl/util/generator/Constant.java b/src/java/org/lwjgl/util/generator/Constant.java index 82b62c1f..b6ca32ca 100644 --- a/src/java/org/lwjgl/util/generator/Constant.java +++ b/src/java/org/lwjgl/util/generator/Constant.java @@ -46,4 +46,6 @@ public @interface Constant { String value(); /** If true, the original parameter will not be removed from the method. */ boolean keepParam() default false; + /** If true, this is a native code constant. */ + boolean isNative() default false; } diff --git a/src/java/org/lwjgl/util/generator/AutoResultSize.java b/src/java/org/lwjgl/util/generator/Extern.java similarity index 87% rename from src/java/org/lwjgl/util/generator/AutoResultSize.java rename to src/java/org/lwjgl/util/generator/Extern.java index d68c404c..b4e8f6fa 100644 --- a/src/java/org/lwjgl/util/generator/AutoResultSize.java +++ b/src/java/org/lwjgl/util/generator/Extern.java @@ -1,50 +1,46 @@ -/* - * 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 - * 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.generator; - -/** - * - * AutoResultSize specifies the size of a returned Buffer - * as an expression. - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@Target(ElementType.METHOD) -public @interface AutoResultSize { - String value(); // The size as a java expression -} +/* + * 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 + * 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.generator; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +/** + * Functions marked with @Extern will not be declared as static in the C implementation. + * This allows other source files to call them. + * + * @author Spasi + */ +@Target(ElementType.METHOD) +public @interface Extern { + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/GenerateAutos.java b/src/java/org/lwjgl/util/generator/GenerateAutos.java index d042c546..2127bd43 100644 --- a/src/java/org/lwjgl/util/generator/GenerateAutos.java +++ b/src/java/org/lwjgl/util/generator/GenerateAutos.java @@ -43,4 +43,6 @@ import java.lang.annotation.ElementType; @Target(ElementType.METHOD) public @interface GenerateAutos { + /** If true, a size variable will be generated. */ + String[] sizeVariables() default {}; } diff --git a/src/java/org/lwjgl/util/generator/GeneratorProcessorFactory.java b/src/java/org/lwjgl/util/generator/GeneratorProcessorFactory.java index 1a8faa4b..79979e7b 100644 --- a/src/java/org/lwjgl/util/generator/GeneratorProcessorFactory.java +++ b/src/java/org/lwjgl/util/generator/GeneratorProcessorFactory.java @@ -32,29 +32,32 @@ package org.lwjgl.util.generator; -import com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; - import java.io.File; import java.io.FileFilter; -import java.util.Collection; -import java.util.Set; -import java.util.Map; import java.util.Arrays; +import java.util.Collection; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import com.sun.mirror.apt.*; +import com.sun.mirror.declaration.AnnotationTypeDeclaration; +import com.sun.mirror.declaration.TypeDeclaration; -import static java.util.Collections.*; import static com.sun.mirror.util.DeclarationVisitors.*; +import static java.util.Collections.*; /** - * * Generator tool for creating the java classes and native code * from an annotated template java interface. * * @author elias_naur * @version $Revision$ - * $Id$ + * $Id$ */ public class GeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener { + private static boolean first_round = true; // Process any set of annotations @@ -78,7 +81,7 @@ public class GeneratorProcessorFactory implements AnnotationProcessorFactory, Ro public AnnotationProcessor getProcessorFor(Set atds, AnnotationProcessorEnvironment env) { // Only process the initial types, not the generated ones - if (first_round) { + if ( first_round ) { env.addListener(this); return new GeneratorProcessor(env); } else @@ -86,6 +89,7 @@ public class GeneratorProcessorFactory implements AnnotationProcessorFactory, Ro } private static class GeneratorProcessor implements AnnotationProcessor { + private final AnnotationProcessorEnvironment env; GeneratorProcessor(AnnotationProcessorEnvironment env) { @@ -97,22 +101,22 @@ public class GeneratorProcessorFactory implements AnnotationProcessorFactory, Ro String typemap_classname = null; boolean generate_error_checks = options.containsKey("-Ageneratechecks"); boolean context_specific = options.containsKey("-Acontextspecific"); - for (String k : options.keySet()) { + for ( String k : options.keySet() ) { int delimiter = k.indexOf('='); - if (delimiter != -1) { - if (k.startsWith("-Atypemap")) { + if ( delimiter != -1 ) { + if ( k.startsWith("-Atypemap") ) { typemap_classname = k.substring(delimiter + 1); } } } - if (typemap_classname == null) + if ( typemap_classname == null ) throw new RuntimeException("No TypeMap class name specified with -Atypemap="); TypeDeclaration lastFile = null; try { long generatorLM = getGeneratorLastModified(); TypeMap type_map = (TypeMap)(Class.forName(typemap_classname).newInstance()); - for (TypeDeclaration typedecl : env.getSpecifiedTypeDeclarations()) { + for ( TypeDeclaration typedecl : env.getSpecifiedTypeDeclarations() ) { lastFile = typedecl; typedecl.accept(getDeclarationScanner(new GeneratorVisitor(env, type_map, generate_error_checks, context_specific, generatorLM), NO_OP)); } @@ -130,7 +134,16 @@ public class GeneratorProcessorFactory implements AnnotationProcessorFactory, Ro * @return time of the latest change */ private static long getGeneratorLastModified() { - final File pck = new File(System.getProperty("user.dir") + "/bin/org/lwjgl/util/generator"); + long lastModified = getDirectoryLastModified("/bin/org/lwjgl/util/generator"); + lastModified = Math.max(lastModified, getDirectoryLastModified("/bin/org/lwjgl/util/generator/openal")); + lastModified = Math.max(lastModified, getDirectoryLastModified("/bin/org/lwjgl/util/generator/opengl")); + lastModified = Math.max(lastModified, getDirectoryLastModified("/bin/org/lwjgl/util/generator/opencl")); + + return lastModified; + } + + private static long getDirectoryLastModified(final String path) { + final File pck = new File(System.getProperty("user.dir") + path); if ( !pck.exists() || !pck.isDirectory() ) return Long.MAX_VALUE; diff --git a/src/java/org/lwjgl/util/generator/GeneratorVisitor.java b/src/java/org/lwjgl/util/generator/GeneratorVisitor.java index a3f74177..8c28287d 100644 --- a/src/java/org/lwjgl/util/generator/GeneratorVisitor.java +++ b/src/java/org/lwjgl/util/generator/GeneratorVisitor.java @@ -37,12 +37,11 @@ import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; +import java.io.*; +import java.lang.annotation.Annotation; +import java.nio.channels.FileChannel; import java.util.*; -import java.io.PrintWriter; -import java.io.IOException; -import java.io.File; - import java.nio.*; /** @@ -68,11 +67,6 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor { this.generatorLM = generatorLM; } - private void validateMethods(InterfaceDeclaration d) { - for (MethodDeclaration method : d.getMethods()) - validateMethod(method); - } - private void validateMethod(MethodDeclaration method) { if (method.isVarArgs()) throw new RuntimeException("Method " + method.getSimpleName() + " is variadic"); @@ -96,13 +90,13 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor { if (method.getAnnotation(CachedResult.class) != null) { if (Utils.getNIOBufferType(Utils.getMethodReturnType(method)) == null) throw new RuntimeException(method + " return type is not a Buffer, but is annotated with CachedResult"); - if (method.getAnnotation(AutoResultSize.class) == null) - throw new RuntimeException(method + " is annotated with CachedResult but misses an AutoResultSize annotation"); + if (method.getAnnotation(AutoSize.class) == null) + throw new RuntimeException(method + " is annotated with CachedResult but misses an AutoSize annotation"); } validateTypes(method, method.getAnnotationMirrors(), method.getReturnType()); } - private void validateType(MethodDeclaration method, Class annotation_type, Class type) { + private void validateType(MethodDeclaration method, Class annotation_type, Class type) { Class[] valid_types = type_map.getValidAnnotationTypes(type); for (int i = 0; i < valid_types.length; i++) if (valid_types[i].equals(annotation_type)) @@ -115,7 +109,11 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor { for (AnnotationMirror annotation : annotations) { NativeType native_type_annotation = NativeTypeTranslator.getAnnotation(annotation, NativeType.class); if (native_type_annotation != null) { - Class annotation_type = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType()); + Class annotation_type = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType()); + /*System.out.println("\nYO:"); + System.out.println("annotation = " + annotation); + System.out.println("native_type_annotation = " + native_type_annotation); + System.out.println("annotation_type = " + annotation_type);*/ Class type = Utils.getJavaType(type_mirror); if (Buffer.class.equals(type)) continue; @@ -172,7 +170,9 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor { } private static void generateMethodNativePointers(PrintWriter writer, MethodDeclaration method) { - writer.println("static " + Utils.getTypedefName(method) + " " + method.getSimpleName() + ";"); + if ( method.getAnnotation(Extern.class) == null ) + writer.print("static "); + writer.println(Utils.getTypedefName(method) + " " + method.getSimpleName() + ";"); } private void generateJavaSource(InterfaceDeclaration d, PrintWriter java_writer) throws IOException { @@ -182,9 +182,15 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor { java_writer.println(); java_writer.println("import org.lwjgl.*;"); java_writer.println("import java.nio.*;"); + Imports imports = d.getAnnotation(Imports.class); + if ( imports != null ) { + for ( String i : imports.value() ) + java_writer.println("import " + i + ";"); + } java_writer.println(); Utils.printDocComment(java_writer, d); - java_writer.print("public "); + if ( d.getAnnotation(Private.class) == null ) + java_writer.print("public "); boolean is_final = Utils.isFinal(d); if (is_final) java_writer.write("final "); @@ -223,8 +229,10 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor { native_writer.println("#include "); type_map.printNativeIncludes(native_writer); native_writer.println(); + //if ( d.getAnnotation(NoTypeDefs.class) == null ) { TypedefsGenerator.generateNativeTypedefs(type_map, native_writer, d.getMethods()); native_writer.println(); + //} if (!context_specific) { generateMethodsNativePointers(native_writer, d.getMethods()); native_writer.println(); @@ -247,29 +255,98 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor { } public void visitInterfaceDeclaration(InterfaceDeclaration d) { - File input = d.getPosition().file(); - File output = new File(env.getOptions().get("-s") + '/' + d.getPackage().getQualifiedName().replace('.', '/'), Utils.getSimpleClassName(d) + ".java"); + final File input = d.getPosition().file(); + final File outputJava = new File(env.getOptions().get("-s") + '/' + d.getPackage().getQualifiedName().replace('.', '/'), Utils.getSimpleClassName(d) + ".java"); PrintWriter java_writer = null; try { - // Skip this class if the output exists and the input has not been modified. - if ( output.exists() && Math.max(input.lastModified(), generatorLM) < output.lastModified() ) + final Collection methods = d.getMethods(); + if ( methods.size() == 0 && d.getFields().size() == 0 ) return; - if (d.getMethods().size() > 0 || d.getFields().size() > 0) { - validateMethods(d); - java_writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, d.getPackage().getQualifiedName(), new File(Utils.getSimpleClassName(d) + ".java"), null); - generateJavaSource(d, java_writer); + // Skip this class if the output exists and the input has not been modified. + if ( outputJava.exists() && Math.max(input.lastModified(), generatorLM) < outputJava.lastModified() ) + return; + + for ( final MethodDeclaration method : methods ) + validateMethod(method); + java_writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, d.getPackage().getQualifiedName(), new File(Utils.getSimpleClassName(d) + ".java"), null); + generateJavaSource(d, java_writer); + + if ( methods.size() > 0 ) { + boolean hasNative = false; + for ( final MethodDeclaration method : methods ) { + Alternate alt_annotation = method.getAnnotation(Alternate.class); + if ( (alt_annotation == null || alt_annotation.nativeAlt()) && method.getAnnotation(Reuse.class) == null ) { + hasNative = true; + break; + } + } + if ( !hasNative ) + return; + + final String outputPath = env.getOptions().get("-d") + '/' + Utils.getNativeQualifiedName(Utils.getQualifiedClassName(d)); + final File outputNative = new File(outputPath + ".c"); + final File outputBackup = new File(outputPath + "_backup.c"); + + // If the native file exists, rename. + final ByteBuffer nativeBefore; + if ( outputNative.exists() ) { + nativeBefore = readFile(outputNative); + outputNative.renameTo(outputBackup); + } else + nativeBefore = null; + + try { + generateNativeSource(d); + + // If the native file did exist, compare with the new file. If they're the same, + // reset the last modified time to avoid ridiculous C compilation times. + if ( nativeBefore != null && outputNative.length() == nativeBefore.capacity() ) { + final ByteBuffer nativeAfter = readFile(outputNative); + boolean same = true; + for ( int i = nativeBefore.position(); i < nativeBefore.limit(); i++ ) { + if ( nativeBefore.get(i) != nativeAfter.get(i) ) { + same = false; + break; + } + } + + if ( same ) { + outputNative.delete(); + outputBackup.renameTo(outputNative); + } + } + } finally { + if ( outputBackup.exists() ) + outputBackup.delete(); + } } - if (d.getMethods().size() > 0) - generateNativeSource(d); } catch (Exception e) { // If anything goes wrong mid-gen, delete output to allow regen next time we run. if ( java_writer != null ) java_writer.close(); - if ( output.exists() ) output.delete(); + if ( outputJava.exists() ) outputJava.delete(); throw new RuntimeException(e); } } + + private static ByteBuffer readFile(final File file) throws IOException { + final FileChannel channel = new FileInputStream(file).getChannel(); + + final long bytesTotal = channel.size(); + final ByteBuffer buffer = ByteBuffer.allocateDirect((int)bytesTotal); + + long bytesRead = 0; + do { + bytesRead += channel.read(buffer); + } while ( bytesRead < bytesTotal ); + buffer.flip(); + + channel.close(); + + return buffer; + } + } diff --git a/src/java/org/lwjgl/util/generator/Helper.java b/src/java/org/lwjgl/util/generator/Helper.java new file mode 100644 index 00000000..b2795256 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/Helper.java @@ -0,0 +1,46 @@ +/* + * 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 + * 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.generator; + +/** + * Method parameters marked with @Helper will be considered Java-API + * parameters and will be ignored when generating native stubs/code. + * + * @author Spasi + */ +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target(ElementType.PARAMETER) +public @interface Helper { + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/Imports.java b/src/java/org/lwjgl/util/generator/Imports.java new file mode 100644 index 00000000..6a278baa --- /dev/null +++ b/src/java/org/lwjgl/util/generator/Imports.java @@ -0,0 +1,46 @@ +/* + * 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 + * 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.generator; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +/** + * This annotation can be used when an extension template needs + * extra imports in its generated class. + * + * @author Spasi + */ +@Target(ElementType.TYPE) +public @interface Imports { + String[] value(); +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/JNITypeTranslator.java b/src/java/org/lwjgl/util/generator/JNITypeTranslator.java index a43330b0..d0294dc2 100644 --- a/src/java/org/lwjgl/util/generator/JNITypeTranslator.java +++ b/src/java/org/lwjgl/util/generator/JNITypeTranslator.java @@ -56,8 +56,13 @@ public class JNITypeTranslator implements TypeVisitor { } public void visitArrayType(ArrayType t) { - if ( "java.lang.CharSequence".equals(t.getComponentType().toString()) ) + final String className = t.getComponentType().toString(); + if ( "java.lang.CharSequence".equals(className) ) signature.append("jobject"); + else if ( "java.nio.ByteBuffer".equals(className) ) + signature.append("jobjectArray"); + else if ( "org.lwjgl.opencl.CLMem".equals(className) ) + signature.append("jobjectArray"); else throw new RuntimeException(t + " is not allowed"); } diff --git a/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java b/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java index 6f07a2ed..860ee6ce 100644 --- a/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java +++ b/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java @@ -41,6 +41,9 @@ package org.lwjgl.util.generator; * $Id$ */ +import org.lwjgl.PointerBuffer; +import org.lwjgl.util.generator.opengl.GLreturn; + import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; @@ -50,7 +53,7 @@ import java.util.*; import java.nio.*; public class JavaMethodsGenerator { - private final static String SAVED_PARAMETER_POSTFIX = "_saved"; + private static final String SAVED_PARAMETER_POSTFIX = "_saved"; public static void generateMethodsJava(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration interface_decl, boolean generate_error_checks, boolean context_specific) { for (MethodDeclaration method : interface_decl.getMethods()) @@ -71,8 +74,14 @@ public class JavaMethodsGenerator { if ( method.getAnnotation(CachedResult.class) != null && !method.getAnnotation(CachedResult.class).isRange() ) { printMethodWithMultiType(env, type_map, writer, interface_decl, method, TypeInfo.getDefaultTypeInfoMap(method), Mode.CACHEDRESULT, generate_error_checks, context_specific); } + + // Skip the native function if we're re-using. + Reuse reuse_annotation = method.getAnnotation(Reuse.class); + if ( reuse_annotation != null ) + return; + Alternate alt_annotation = method.getAnnotation(Alternate.class); - if ( alt_annotation == null || alt_annotation.nativeAlt() ) { + if ( alt_annotation == null || (alt_annotation.nativeAlt() && !alt_annotation.skipNative()) ) { if ( alt_annotation != null && method.getSimpleName().equals(alt_annotation.value()) ) throw new RuntimeException("An alternate function with native code should have a different name than the main function."); printJavaNativeStub(writer, method, Mode.NORMAL, generate_error_checks, context_specific); @@ -90,12 +99,12 @@ public class JavaMethodsGenerator { Utils.printDocComment(writer, method); writer.print("\tpublic static native "); } - printResultType(writer, method, true); + writer.print(getResultType(method, true)); 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 = generateParametersJava(writer, method, TypeInfo.getDefaultTypeInfoMap(method), true, mode); + boolean first_parameter = generateParametersJava(writer, method, TypeInfo.getDefaultTypeInfoMap(method), true, true, mode); if (context_specific) { if (!first_parameter) writer.print(", "); @@ -104,10 +113,14 @@ public class JavaMethodsGenerator { writer.println(");"); } - private static boolean generateParametersJava(PrintWriter writer, MethodDeclaration method, Map typeinfos_instance, - boolean native_stub, Mode mode) { + private static boolean generateParametersJava(PrintWriter writer, MethodDeclaration method, Map typeinfos_instance, boolean native_stub, final boolean printTypes, Mode mode) { boolean first_parameter = true; for (ParameterDeclaration param : method.getParameters()) { + if ( native_stub && param.getAnnotation(Helper.class) != null ) + continue; + final Constant constant_annotation = param.getAnnotation(Constant.class); + if ( constant_annotation != null && constant_annotation.isNative() ) + continue; AnnotationMirror auto_annotation_mirror = Utils.getParameterAutoAnnotation(param); boolean hide_auto_parameter = mode == Mode.NORMAL && !native_stub && auto_annotation_mirror != null; if (hide_auto_parameter) { @@ -119,44 +132,53 @@ public class JavaMethodsGenerator { if (!first_parameter) writer.print(", "); first_parameter = false; - writer.print("boolean " + TypeInfo.UNSIGNED_PARAMETER_NAME); + if ( printTypes ) + writer.print("boolean "); + writer.print( TypeInfo.UNSIGNED_PARAMETER_NAME); } } } else if ( param.getAnnotation(Result.class) == null && (native_stub || ((param.getAnnotation(Constant.class) == null || param.getAnnotation(Constant.class).keepParam()) && !Utils.isReturnParameter(method, param))) - && (getAutoTypeParameter(method, param) == null || mode != Mode.AUTOS) - ) - { - TypeInfo type_info = typeinfos_instance.get(param); - first_parameter = generateParameterJava(writer, param, type_info, native_stub, first_parameter, mode); + && (mode != Mode.AUTOS || getAutoTypeParameter(method, param) == null) + ) { + first_parameter = generateParameterJava(writer, param, typeinfos_instance.get(param), native_stub, printTypes, first_parameter, mode); } } CachedResult cached_result_annotation = method.getAnnotation(CachedResult.class); TypeMirror result_type = Utils.getMethodReturnType(method); if ((native_stub && Utils.getNIOBufferType(result_type) != null) || Utils.needResultSize(method)) { - if (cached_result_annotation == null || !cached_result_annotation.isRange()) { - if (!first_parameter) - writer.print(", "); - first_parameter = false; - writer.print("long " + Utils.RESULT_SIZE_NAME); + AutoSize auto_size_annotation = method.getAnnotation(AutoSize.class); + if ( auto_size_annotation == null || !auto_size_annotation.isNative() ) { + if (cached_result_annotation == null || !cached_result_annotation.isRange()) { + if (!first_parameter) + writer.print(", "); + first_parameter = false; + if ( printTypes ) + writer.print("long "); + writer.print(Utils.RESULT_SIZE_NAME); + } } } if (cached_result_annotation != null) { if (!first_parameter) writer.print(", "); - if ( mode == Mode.CACHEDRESULT ) - writer.print("long " + Utils.CACHED_BUFFER_LENGTH_NAME + ", "); + if ( mode == Mode.CACHEDRESULT ) { + if ( printTypes ) + writer.print("long "); + writer.print(Utils.CACHED_BUFFER_LENGTH_NAME + ", "); + } first_parameter = false; - printResultType(writer, method, native_stub); + if ( printTypes ) + writer.print(getResultType(method, native_stub)); writer.print(" " + Utils.CACHED_BUFFER_NAME); } return first_parameter; } - private static boolean generateParameterJava(PrintWriter writer, ParameterDeclaration param, TypeInfo type_info, boolean native_stub, boolean first_parameter, Mode mode) { + private static boolean generateParameterJava(PrintWriter writer, ParameterDeclaration param, TypeInfo type_info, boolean native_stub, final boolean printTypes, boolean first_parameter, Mode mode) { Class buffer_type = Utils.getNIOBufferType(param.getType()); if (!first_parameter) writer.print(", "); @@ -164,18 +186,23 @@ public class JavaMethodsGenerator { if (bo_annotation != null && mode == Mode.BUFFEROBJECT) { if (buffer_type == null) throw new RuntimeException("type of " + param + " is not a nio Buffer parameter but is annotated as buffer object"); - writer.print("long " + param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX); + if ( printTypes ) + writer.print("long "); + writer.print(param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX); } else { - if ( native_stub && param.getAnnotation(GLpointer.class) != null ) - writer.print("long"); + if ( native_stub && param.getAnnotation(PointerWrapper.class) != null ) + writer.print("long "); else { Class type = type_info.getType(); - if ( native_stub && (type == CharSequence.class || type == CharSequence[].class) ) - writer.print("ByteBuffer"); - else - writer.print(type_info.getType().getSimpleName()); + if ( native_stub && (type == CharSequence.class || type == CharSequence[].class || type == PointerBuffer.class) ) + writer.print("ByteBuffer "); + else if ( printTypes ) + writer.print(type_info.getType().getSimpleName() + " "); } - writer.print(" " + param.getSimpleName()); + AutoSize auto_size_annotation = param.getAnnotation(AutoSize.class); + if ( auto_size_annotation != null ) + writer.print(auto_size_annotation.value() + "_"); + writer.print(param.getSimpleName()); if ( native_stub && buffer_type != null ) writer.print(", int " + param.getSimpleName() + NativeMethodStubsGenerator.BUFFER_POSITION_POSTFIX); } @@ -205,8 +232,11 @@ public class JavaMethodsGenerator { private static void printMethodWithMultiType(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method, Map typeinfos_instance, Mode mode, boolean generate_error_checks, boolean context_specific) { Utils.printDocComment(writer, method); - writer.print("\tpublic static "); - printResultType(writer, method, false); + if ( interface_decl.getAnnotation(Private.class) == null && method.getAnnotation(Private.class) == null ) + writer.print("\tpublic static "); + else + writer.print("\tstatic "); + writer.print(getResultType(method, false)); StripPostfix strip_annotation = method.getAnnotation(StripPostfix.class); String method_name; Alternate alt_annotation = method.getAnnotation(Alternate.class); @@ -214,32 +244,60 @@ public class JavaMethodsGenerator { if (strip_annotation != null && mode == Mode.NORMAL) method_name = getPostfixStrippedName(type_map, interface_decl, method); writer.print(" " + method_name + "("); - generateParametersJava(writer, method, typeinfos_instance, false, mode); - TypeMirror result_type = Utils.getMethodReturnType(method); + generateParametersJava(writer, method, typeinfos_instance, false, true, mode); writer.println(") {"); + + final TypeMirror result_type = Utils.getMethodReturnType(method); + boolean has_result = !result_type.equals(env.getTypeUtils().getVoidType()); + + final Reuse reuse_annotation = method.getAnnotation(Reuse.class); + if ( reuse_annotation != null ) { + writer.print("\t\t"); + if ( has_result || method.getAnnotation(GLreturn.class) != null ) + writer.print("return "); + + writer.print(reuse_annotation.value() + "." + method_name + "("); + generateParametersJava(writer, method, typeinfos_instance, false, false, mode); + writer.println(");\n\t}"); + return; + } + if (context_specific) { - writer.println("\t\tContextCapabilities caps = GLContext.getCapabilities();"); - writer.print("\t\tlong " + Utils.FUNCTION_POINTER_VAR_NAME + " = caps."); + type_map.printCapabilitiesInit(writer); + writer.print("\t\tlong " + Utils.FUNCTION_POINTER_VAR_NAME + " = " + type_map.getCapabilities() + "."); writer.println(Utils.getFunctionAddressName(interface_decl, method, true) + ";"); writer.print("\t\tBufferChecks.checkFunctionAddress("); writer.println(Utils.FUNCTION_POINTER_VAR_NAME + ");"); } - Code code_annotation = method.getAnnotation(Code.class); - if (code_annotation != null) + final Code code_annotation = method.getAnnotation(Code.class); + if (code_annotation != null && code_annotation.value().length() > 0) writer.println(code_annotation.value()); printBufferObjectChecks(writer, method, mode); - printParameterChecks(writer, method, typeinfos_instance, mode); + printParameterChecks(writer, method, typeinfos_instance, mode, generate_error_checks); printParameterCaching(writer, interface_decl, method, mode); - writer.print("\t\t"); - boolean has_result = !result_type.equals(env.getTypeUtils().getVoidType()); - if (has_result) { - printResultType(writer, method, false); - writer.print(" " + Utils.RESULT_VAR_NAME + " = "); - if ( method.getAnnotation(GLpointer.class) != null ) - writer.print("new " + method.getReturnType() + "("); - } - if ( method.getAnnotation(GLreturn.class) != null ) { + if ( code_annotation != null && code_annotation.javaBeforeNative().length() > 0 ) + writer.println(code_annotation.javaBeforeNative()); + writer.print("\t\t"); + + final PointerWrapper pointer_wrapper_annotation = method.getAnnotation(PointerWrapper.class); + if (has_result) { + writer.print(getResultType(method, false) + " " + Utils.RESULT_VAR_NAME); + + if ( code_annotation != null && code_annotation.tryBlock() ) { + writer.print(" = " + getDefaultResultValue(method)); + writer.println(";\n\t\ttry {"); + writer.print("\t\t\t" + Utils.RESULT_VAR_NAME); + } + + writer.print(" = "); + if ( pointer_wrapper_annotation != null ) { + if ( pointer_wrapper_annotation.factory().length() > 0 ) + writer.print(pointer_wrapper_annotation.factory() + "("); + else + writer.print("new " + getResultType(method, false) + "("); + } + } else if ( method.getAnnotation(GLreturn.class) != null ) { has_result = true; Utils.printGLReturnPre(writer, method, method.getAnnotation(GLreturn.class)); } @@ -253,22 +311,36 @@ public class JavaMethodsGenerator { writer.print(", "); writer.print(Utils.FUNCTION_POINTER_VAR_NAME); } - if ( has_result && method.getAnnotation(GLpointer.class) != null ) + if ( has_result && pointer_wrapper_annotation != null ) { writer.print(")"); + if ( pointer_wrapper_annotation.params().length() > 0 ) + writer.print(", " + pointer_wrapper_annotation.params()); + } writer.println(");"); + + if ( code_annotation != null && code_annotation.javaAfterNative().length() > 0 ) + writer.println(code_annotation.javaAfterNative()); + + final String tabs = code_annotation != null && code_annotation.tryBlock() ? "\t\t\t" : "\t\t"; if (generate_error_checks && method.getAnnotation(NoErrorCheck.class) == null) - writer.println("\t\t" + type_map.getErrorCheckMethodName() + ";"); + type_map.printErrorCheckMethod(writer, method, tabs); // DISABLED: indirect buffer support //printNondirectParameterCopies(writer, method, mode); if (has_result) { if ( method.getAnnotation(GLreturn.class) == null ) { if ( ByteBuffer.class.equals(Utils.getJavaType(result_type)) ) - writer.println("\t\treturn LWJGLUtil.CHECKS && " + Utils.RESULT_VAR_NAME + " == null ? null : " + Utils.RESULT_VAR_NAME + ".order(ByteOrder.nativeOrder());"); // safeNewBuffer returns a direct ByteBuffer with BIG_ENDIAN order. + writer.println(tabs + "return LWJGLUtil.CHECKS && " + Utils.RESULT_VAR_NAME + " == null ? null : " + Utils.RESULT_VAR_NAME + ".order(ByteOrder.nativeOrder());"); // safeNewBuffer returns a direct ByteBuffer with BIG_ENDIAN order. else - writer.println("\t\treturn " + Utils.RESULT_VAR_NAME + ";"); + writer.println(tabs + "return " + Utils.RESULT_VAR_NAME + ";"); } else Utils.printGLReturnPost(writer, method, method.getAnnotation(GLreturn.class)); } + + if ( code_annotation != null && code_annotation.tryBlock() ) { + writer.println("\t\t} finally {"); + writer.println(code_annotation.javaFinally()); + writer.println("\t\t}"); + } writer.println("\t}"); } @@ -296,7 +368,7 @@ public class JavaMethodsGenerator { else if (annotation_type.equals(AutoSize.class)) parameter_name = param.getAnnotation(AutoSize.class).value(); else - throw new RuntimeException("Unkown annotation type " + annotation_type); + throw new RuntimeException("Unknown annotation type " + annotation_type); if (target_parameter.getSimpleName().equals(parameter_name)) return param; } @@ -368,6 +440,7 @@ public class JavaMethodsGenerator { private static boolean printMethodCallArgument(PrintWriter writer, MethodDeclaration method, ParameterDeclaration param, Map typeinfos_instance, Mode mode, boolean first_parameter) { if (!first_parameter) writer.print(", "); + AnnotationMirror auto_annotation = Utils.getParameterAutoAnnotation(param); Constant constant_annotation = param.getAnnotation(Constant.class); if (constant_annotation != null) { @@ -375,31 +448,34 @@ public class JavaMethodsGenerator { } else if (auto_annotation != null && mode == Mode.NORMAL) { Class param_type = NativeTypeTranslator.getClassFromType(auto_annotation.getAnnotationType()); if (AutoType.class.equals(param_type)) { - AutoType auto_type_annotation = param.getAnnotation(AutoType.class); - String auto_parameter_name = auto_type_annotation.value(); - ParameterDeclaration auto_parameter = Utils.findParameter(method, auto_parameter_name); - String auto_type = typeinfos_instance.get(auto_parameter).getAutoType(); - if (auto_type == null) + final AutoType auto_type_annotation = param.getAnnotation(AutoType.class); + final ParameterDeclaration auto_parameter = Utils.findParameter(method, auto_type_annotation.value()); + final String auto_type = typeinfos_instance.get(auto_parameter).getAutoType(); + if ( auto_type == null ) throw new RuntimeException("No auto type for parameter " + param.getSimpleName() + " in method " + method); writer.print(auto_type); } else if (AutoSize.class.equals(param_type)) { - AutoSize auto_type_annotation = param.getAnnotation(AutoSize.class); - String auto_parameter_name = auto_type_annotation.value(); - ParameterDeclaration auto_target_param = Utils.findParameter(method, auto_parameter_name); - TypeInfo auto_target_type_info = typeinfos_instance.get(auto_target_param); - if ( auto_type_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 - boolean shift_remaining = !hasAnyParameterAutoTypeAnnotation(method, auto_target_param) && Utils.isParameterMultiTyped(auto_target_param); - if (shift_remaining) { - int shifting = getBufferElementSizeExponent(auto_target_type_info.getType()); - if (shifting > 0) - writer.print(" << " + shifting); + 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("("); } - writer.print(")"); - writer.print(auto_type_annotation.expression()); + 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); } else { @@ -407,14 +483,15 @@ public class JavaMethodsGenerator { writer.print(param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX); } else { Class type = typeinfos_instance.get(param).getType(); + Check check_annotation = param.getAnnotation(Check.class); boolean hide_buffer = mode == Mode.AUTOS && getAutoTypeParameter(method, param) != null; - if (hide_buffer) + if (hide_buffer) { writer.print("null"); - else { + } else { if ( type == CharSequence.class || type == CharSequence[].class ) { final String offset = Utils.getStringOffset(method, param); - writer.print("APIUtils.getBuffer"); + writer.print("APIUtil.getBuffer"); if ( param.getAnnotation(NullTerminated.class) != null ) writer.print("NT"); writer.print("(" + param.getSimpleName()); @@ -422,24 +499,37 @@ public class JavaMethodsGenerator { writer.print(", " + offset); writer.print(")"); hide_buffer = true; - } else + } else { + final AutoSize auto_size_annotation = param.getAnnotation(AutoSize.class); + if ( auto_size_annotation != null ) + writer.print(auto_size_annotation.value() + "_"); writer.print(param.getSimpleName()); + if ( PointerBuffer.class.isAssignableFrom(type) ) { + if ( check_annotation != null && check_annotation.canBeNull() ) + writer.print(" != null ? " + param.getSimpleName()); + writer.print(".getBuffer()"); + if ( check_annotation != null && check_annotation.canBeNull() ) + writer.print(" : null"); + } + } } Class buffer_type = Utils.getNIOBufferType(param.getType()); if (buffer_type != null) { writer.print(", "); if (!hide_buffer) { - TypeInfo type_info = typeinfos_instance.get(param); - Check check_annotation = param.getAnnotation(Check.class); int shifting; - if (Utils.getNIOBufferType(param.getType()).equals(Buffer.class)) - shifting = getBufferElementSizeExponent(type_info.getType()); - else + if (Utils.getNIOBufferType(param.getType()).equals(Buffer.class)) { + shifting = getBufferElementSizeExponent(type == Buffer.class ? ByteBuffer.class : type); // TODO: This will always throw an exception + //shifting = 0; + } else shifting = 0; writer.print(param.getSimpleName()); if (check_annotation != null && check_annotation.canBeNull()) writer.print(" != null ? " + param.getSimpleName()); - writer.print(".position()"); + if ( type == PointerBuffer.class ) + writer.print(".positionByte()"); + else + writer.print(".position()"); if (shifting > 0) writer.print(" << " + shifting); if (check_annotation != null && check_annotation.canBeNull()) @@ -449,8 +539,8 @@ public class JavaMethodsGenerator { writer.print(offset == null ? "0" : offset); } else writer.print("0"); - } else { - GLpointer pointer_annotation = param.getAnnotation(GLpointer.class); + } else if ( type != long.class ) { + PointerWrapper pointer_annotation = param.getAnnotation(PointerWrapper.class); if ( pointer_annotation != null ) { if ( pointer_annotation.canBeNull() ) writer.print(" == null ? 0 : " + param.getSimpleName()); @@ -464,30 +554,35 @@ public class JavaMethodsGenerator { private static boolean printMethodCallArguments(PrintWriter writer, MethodDeclaration method, Map typeinfos_instance, Mode mode) { boolean first_parameter = true; - for (ParameterDeclaration param : method.getParameters()) - if (param.getAnnotation(Result.class) == null) { + for ( ParameterDeclaration param : method.getParameters() ) { + if ( param.getAnnotation(Result.class) != null || param.getAnnotation(Helper.class) != null ) + continue; + + 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); - } + } if (Utils.getNIOBufferType(Utils.getMethodReturnType(method)) != null) { if (method.getAnnotation(CachedResult.class) != null && method.getAnnotation(CachedResult.class).isRange()) { first_parameter = false; Utils.printExtraCallArguments(writer, method, ""); } else { - if (!first_parameter) - writer.print(", "); - first_parameter = false; + AutoSize auto_size_annotation = method.getAnnotation(AutoSize.class); + if ( auto_size_annotation == null || !auto_size_annotation.isNative() ) { + if (!first_parameter) + writer.print(", "); + first_parameter = false; - String result_size_expression; - if ( mode == Mode.CACHEDRESULT ) - result_size_expression = Utils.CACHED_BUFFER_LENGTH_NAME; - else { - AutoResultSize auto_result_size_annotation = method.getAnnotation(AutoResultSize.class); - if (auto_result_size_annotation == null) + String result_size_expression; + if ( mode == Mode.CACHEDRESULT ) + result_size_expression = Utils.CACHED_BUFFER_LENGTH_NAME; + else if ( auto_size_annotation == null ) result_size_expression = Utils.RESULT_SIZE_NAME; else - result_size_expression = auto_result_size_annotation.value(); + result_size_expression = auto_size_annotation.value(); + + Utils.printExtraCallArguments(writer, method, result_size_expression); } - Utils.printExtraCallArguments(writer, method, result_size_expression); } } return first_parameter; @@ -531,14 +626,33 @@ public class JavaMethodsGenerator { } } - private static void printParameterChecks(PrintWriter writer, MethodDeclaration method, Map typeinfos, Mode mode) { + private static void printParameterChecks(PrintWriter writer, MethodDeclaration method, Map typeinfos, Mode mode, final boolean generate_error_checks) { + if ( mode == Mode.NORMAL ) { + final GenerateAutos gen_autos_annotation = method.getAnnotation(GenerateAutos.class); + if ( gen_autos_annotation != null && gen_autos_annotation.sizeVariables().length > 0 ) { + // For the auto-generated parameters, declare and init a size variable (that can be reused by @Code) + for ( final ParameterDeclaration param : method.getParameters() ) { + if ( Arrays.binarySearch(gen_autos_annotation.sizeVariables(), param.getSimpleName()) >= 0 ) { + final int shifting = getBufferElementSizeExponent(typeinfos.get(param).getType()); + final Check check_annotation = param.getAnnotation(Check.class); + + writer.print("\t\tlong " + param.getSimpleName() + "_size = "); + if ( check_annotation == null || !check_annotation.canBeNull() ) + writer.println(param.getSimpleName() + ".remaining() << " + shifting + ";"); + else + writer.println(param.getSimpleName() + " == null ? 0 : " + param.getSimpleName() + ".remaining() << " + shifting + ";"); + } + } + } + } + for (ParameterDeclaration param : method.getParameters()) { Class java_type = Utils.getJavaType(param.getType()); - if (Utils.isAddressableType(java_type) && + if ( java_type.isArray() || (Utils.isAddressableType(java_type) && (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) && (mode != Mode.AUTOS || getAutoTypeParameter(method, param) == null) && param.getAnnotation(Result.class) == null && - !Utils.isReturnParameter(method, param) ) { + !Utils.isReturnParameter(method, param)) ) { String check_value = null; boolean can_be_null = false; Check check_annotation = param.getAnnotation(Check.class); @@ -546,59 +660,115 @@ public class JavaMethodsGenerator { check_value = check_annotation.value(); can_be_null = check_annotation.canBeNull(); } - NullTerminated null_terminated = param.getAnnotation(NullTerminated.class); - if (Buffer.class.isAssignableFrom(java_type) && param.getAnnotation(Constant.class) == null) { + if ((Buffer.class.isAssignableFrom(java_type) || PointerBuffer.class.isAssignableFrom(java_type)) && param.getAnnotation(Constant.class) == null) { boolean indirect_buffer_allowed = false && param.getAnnotation(CachedReference.class) == null; // DISABLED: indirect buffer support boolean out_parameter = param.getAnnotation(OutParameter.class) != null; TypeInfo typeinfo = typeinfos.get(param); - printParameterCheck(writer, param.getSimpleName(), typeinfo.getType().getSimpleName(), check_value, can_be_null, null_terminated, indirect_buffer_allowed, out_parameter); + printParameterCheck(writer, method, param.getSimpleName(), typeinfo.getType().getSimpleName(), check_value, can_be_null, param.getAnnotation(NullTerminated.class), indirect_buffer_allowed, out_parameter, generate_error_checks); } else if ( String.class.equals(java_type)) { if (!can_be_null) writer.println("\t\tBufferChecks.checkNotNull(" + param.getSimpleName() + ");"); + } else if ( java_type.isArray() ) { + final TypeInfo typeinfo = typeinfos.get(param); + printArrayParameterCheck(writer, param.getSimpleName(), typeinfo.getType().getSimpleName(), check_value, can_be_null); } } } if (method.getAnnotation(CachedResult.class) != null) - printParameterCheck(writer, Utils.CACHED_BUFFER_NAME, null, null, true, null, false, false); + printParameterCheck(writer, method, Utils.CACHED_BUFFER_NAME, null, null, true, null, false, false, generate_error_checks); } - private static void printParameterCheck(PrintWriter writer, String name, String type, String check_value, boolean can_be_null, NullTerminated null_terminated, boolean indirect_buffer_allowed, boolean out_parameter) { + private static void printParameterCheck(PrintWriter writer, MethodDeclaration method, String name, String type, String check_value, boolean can_be_null, NullTerminated null_terminated, boolean indirect_buffer_allowed, boolean out_parameter, final boolean generate_error_checks) { if (indirect_buffer_allowed && out_parameter) { writer.println("\t\t" + type + " " + name + SAVED_PARAMETER_POSTFIX + " = " + name + ";"); } + String tabs; if (can_be_null) { - writer.println("\t\tif (" + name + " != null)"); - writer.print("\t"); - } + writer.print("\t\tif (" + name + " != null)"); + if ( null_terminated != null ) + writer.println(" {"); + else + writer.println(); + tabs = "\t\t\t"; + } else + tabs = "\t\t"; if (indirect_buffer_allowed) { - writer.print("\t\t" + name + " = NondirectBufferWrapper.wrap"); + writer.print(tabs + name + " = NondirectBufferWrapper.wrap"); if (out_parameter) writer.print("NoCopy"); } else - writer.print("\t\tBufferChecks.check"); - if (check_value != null && !"".equals(check_value) ) { - writer.print("Buffer(" + name + ", " + check_value); + writer.print(tabs + "BufferChecks.check"); + if (check_value != null && check_value.length() > 0) { + writer.print("Buffer"); + if ( "Buffer".equals(type) ) + writer.print("Size"); // Check size only, Buffer.isDirect() was added in 1.6, cannot use yet. TODO: Remove? + writer.print("(" + name + ", " + check_value); } else { writer.print("Direct(" + name); } writer.println(");"); + if ( can_be_null && generate_error_checks ) { + final Check check_annotation = method.getAnnotation(Check.class); + if ( check_annotation != null && check_annotation.value().equals(name) ) { + writer.println("\t\telse"); + writer.println("\t\t\t" + name + " = APIUtil.getBufferIntDebug();"); // Use an exclusive buffer here + } + } if (null_terminated != null) { - writer.print("\t\tBufferChecks.checkNullTerminated("); + writer.print(tabs + "BufferChecks.checkNullTerminated("); writer.print(name); if ( null_terminated.value().length() > 0 ) { writer.print(", "); writer.print(null_terminated.value()); } writer.println(");"); + if ( can_be_null ) + writer.println("\t\t}"); } } - private static void printResultType(PrintWriter writer, MethodDeclaration method, boolean native_stub) { - if ( native_stub && method.getAnnotation(GLpointer.class) != null ) - writer.print("long"); - else if ( !native_stub && method.getAnnotation(GLreturn.class) != null ) - writer.print(Utils.getMethodReturnType(method, method.getAnnotation(GLreturn.class), false)); - else - writer.print(Utils.getMethodReturnType(method).toString()); + private static void printArrayParameterCheck(PrintWriter writer, String name, String type, String check_value, boolean can_be_null) { + String tabs; + if ( can_be_null ) { + writer.println("\t\tif (" + name + " != null)"); + tabs = "\t\t\t"; + } else + tabs = "\t\t"; + + writer.print(tabs + "BufferChecks.checkArray(" + name); + if ( check_value != null && check_value.length() > 0) + writer.print(", " + check_value); + writer.println(");"); } + + private static String getResultType(MethodDeclaration method, boolean native_stub) { + if ( native_stub && method.getAnnotation(PointerWrapper.class) != null ) + return "long"; + else if ( !native_stub && method.getAnnotation(GLreturn.class) != null ) + return Utils.getMethodReturnType(method, method.getAnnotation(GLreturn.class), false); + else + return Utils.getJavaType(Utils.getMethodReturnType(method)).getSimpleName(); + } + + private static String getDefaultResultValue(MethodDeclaration method) { + if ( method.getAnnotation(GLreturn.class) != null ) { + final String type = Utils.getMethodReturnType(method, method.getAnnotation(GLreturn.class), false); + if ( "boolean".equals(type) ) + return "false"; + else if ( Character.isLowerCase(type.charAt(0)) ) + return "0"; + else + return "null"; + } else { + final Class type = Utils.getJavaType(Utils.getMethodReturnType(method)); + if ( type.isPrimitive() ) { + if ( type == boolean.class ) + return "false"; + else + return "0"; + } else + return "null"; + } + } + } diff --git a/src/java/org/lwjgl/util/generator/JavaTypeTranslator.java b/src/java/org/lwjgl/util/generator/JavaTypeTranslator.java index 721f16ef..69e93afe 100644 --- a/src/java/org/lwjgl/util/generator/JavaTypeTranslator.java +++ b/src/java/org/lwjgl/util/generator/JavaTypeTranslator.java @@ -32,11 +32,14 @@ package org.lwjgl.util.generator; +import org.lwjgl.opencl.CLMem; + +import java.nio.ByteBuffer; + import com.sun.mirror.type.*; import com.sun.mirror.util.*; /** - * * A TypeVisitor that translates (annotated) TypeMirrors to * java types (represented by a Class) * @@ -56,10 +59,42 @@ public class JavaTypeTranslator implements TypeVisitor { } public void visitArrayType(ArrayType t) { - if ( "java.lang.CharSequence".equals(t.getComponentType().toString()) ) + final TypeMirror componentType = t.getComponentType(); + if ( componentType instanceof PrimitiveType ) { + type = getPrimitiveArrayClassFromKind(((PrimitiveType)componentType).getKind()); + } else { + try { + final Class c = Class.forName(t.getComponentType().toString()); + if ( CharSequence.class.isAssignableFrom(c) || ByteBuffer.class.isAssignableFrom(c) || org.lwjgl.PointerWrapper.class.isAssignableFrom(c) ) + type = Class.forName("[L" + t.getComponentType() + ";"); + else { + throw new RuntimeException(t + " is not allowed"); + } + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + + /* + final String className = t.getComponentType().toString(); + if ( "java.lang.CharSequence".equals(className) ) type = CharSequence[].class; + else if ( "java.nio.ByteBuffer".equals(className) ) + type = ByteBuffer[].class; + else if ( "org.lwjgl.opencl.CLMem".equals(className) ) + type = CLMem[].class; else throw new RuntimeException(t + " is not allowed"); + //*/ + /* + try { + System.out.println("t = " + t); + System.out.println("t.getClass() = " + t.getClass()); + System.out.println("t.getComponentType() = " + t.getComponentType()); + type = Class.forName(t.toString()); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + }*/ } public static Class getPrimitiveClassFromKind(PrimitiveType.Kind kind) { @@ -83,6 +118,27 @@ public class JavaTypeTranslator implements TypeVisitor { } } + private static Class getPrimitiveArrayClassFromKind(PrimitiveType.Kind kind) { + switch ( kind ) { + case LONG: + return long[].class; + case INT: + return int[].class; + case DOUBLE: + return double[].class; + case FLOAT: + return float[].class; + case SHORT: + return short[].class; + case BYTE: + return byte[].class; + case BOOLEAN: + return boolean[].class; + default: + throw new RuntimeException(kind + " is not allowed"); + } + } + public void visitPrimitiveType(PrimitiveType t) { type = getPrimitiveClassFromKind(t.getKind()); } diff --git a/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java b/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java index 858df19f..dfbc4c49 100644 --- a/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java +++ b/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java @@ -41,6 +41,8 @@ package org.lwjgl.util.generator; * $Id$ */ +import org.lwjgl.PointerBuffer; + import com.sun.mirror.apt.*; import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; @@ -52,12 +54,13 @@ import java.nio.*; public class NativeMethodStubsGenerator { private static final String BUFFER_ADDRESS_POSTFIX = "_address"; public static final String BUFFER_POSITION_POSTFIX = "_position"; - private static final String STRING_LIST_POSTFIX = "_str"; + private static final String STRING_LIST_NAME = "_str"; + private static final String POINTER_LIST_NAME = "_ptr"; public static void generateNativeMethodStubs(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration d, boolean generate_error_checks, boolean context_specific) { for (MethodDeclaration method : d.getMethods()) { Alternate alt_annotation = method.getAnnotation(Alternate.class); - if ( alt_annotation != null && !alt_annotation.nativeAlt() ) + if ( (alt_annotation != null && (!alt_annotation.nativeAlt() || alt_annotation.skipNative())) || method.getAnnotation(Reuse.class) != null ) continue; generateMethodStub(env, type_map, writer, Utils.getQualifiedClassName(d), method, Mode.NORMAL, generate_error_checks, context_specific); if (Utils.hasMethodBufferObjectParameter(method)) @@ -66,16 +69,20 @@ public class NativeMethodStubsGenerator { } private static void generateParameters(PrintWriter writer, Collection params, Mode mode) { - for (ParameterDeclaration param : params) - if (param.getAnnotation(Result.class) == null) + for (ParameterDeclaration param : params) { + if ( param.getAnnotation(Helper.class) != null || param.getAnnotation(Result.class) != null ) + continue; + final Constant constant_annotation = param.getAnnotation(Constant.class); + if ( constant_annotation == null || !constant_annotation.isNative() ) generateParameter(writer, param, mode); + } } private static void generateParameter(PrintWriter writer, ParameterDeclaration param, Mode mode) { writer.print(", "); if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) { writer.print("jlong " + param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX); - } else if ( param.getAnnotation(GLpointer.class) != null ) { + } else if ( param.getAnnotation(PointerWrapper.class) != null ) { writer.print("jlong " + param.getSimpleName()); } else { JNITypeTranslator translator = new JNITypeTranslator(); @@ -92,9 +99,11 @@ public class NativeMethodStubsGenerator { else writer.print("JNIEXPORT "); - TypeMirror result_type = Utils.getMethodReturnType(method); + final TypeMirror result_type = Utils.getMethodReturnType(method); + final CachedResult cached_result_annotation = method.getAnnotation(CachedResult.class); + final AutoSize auto_size_annotation = method.getAnnotation(AutoSize.class); - if ( method.getAnnotation(GLpointer.class) != null ) { + if ( method.getAnnotation(PointerWrapper.class) != null ) { writer.print("jlong"); } else { JNITypeTranslator translator = new JNITypeTranslator(); @@ -109,8 +118,7 @@ public class NativeMethodStubsGenerator { writer.print("(JNIEnv *env, jclass clazz"); generateParameters(writer, method.getParameters(), mode); if (Utils.getNIOBufferType(result_type) != null) { - CachedResult cached_result_annotation = method.getAnnotation(CachedResult.class); - if (cached_result_annotation == null || !cached_result_annotation.isRange()) + if ( (cached_result_annotation == null || !cached_result_annotation.isRange()) && (auto_size_annotation == null || !auto_size_annotation.isNative()) ) writer.print(", jlong " + Utils.RESULT_SIZE_NAME); if (cached_result_annotation != null) writer.print(", jobject " + Utils.CACHED_BUFFER_NAME); @@ -119,6 +127,7 @@ public class NativeMethodStubsGenerator { writer.print(", jlong " + Utils.FUNCTION_POINTER_VAR_NAME); } writer.println(") {"); + generateBufferParameterAddresses(type_map, writer, method, mode); Alternate alt_annotation = method.getAnnotation(Alternate.class); if (context_specific) { @@ -127,49 +136,59 @@ public class NativeMethodStubsGenerator { writer.print(" = (" + typedef_name + ")((intptr_t)"); writer.println(Utils.FUNCTION_POINTER_VAR_NAME + ");"); } - generateStringListInits(writer, method.getParameters()); + + final Code code_annotation = method.getAnnotation(Code.class); + + final boolean hasResult = !result_type.equals(env.getTypeUtils().getVoidType()); + final boolean resultPreDeclare = hasResult && (hasPointerArrayInits(method.getParameters()) || (code_annotation != null && (code_annotation.nativeAfterVars().length() > 0 || code_annotation.nativeBeforeCall().length() > 0))); + if ( resultPreDeclare ) + printResultParam(type_map, writer, method, result_type, true); + + if ( code_annotation != null && code_annotation.nativeAfterVars().length() > 0 ) + writer.println(code_annotation.nativeAfterVars()); + + generatePointerArrayInits(type_map, writer, method.getParameters()); + + if ( code_annotation != null && code_annotation.nativeBeforeCall().length() > 0 ) + writer.println(code_annotation.nativeBeforeCall()); + writer.print("\t"); - if (!result_type.equals(env.getTypeUtils().getVoidType())) { - Declaration return_declaration; - ParameterDeclaration result_param = Utils.getResultParameter(method); - if (result_param != null) - return_declaration = result_param; - else - return_declaration = method; - NativeTypeTranslator native_translator = new NativeTypeTranslator(type_map, return_declaration); - result_type.accept(native_translator); - writer.print(native_translator.getSignature() + " " + Utils.RESULT_VAR_NAME); - if (result_param != null) { - writer.println(";"); - writer.print("\t"); - } else - writer.print(" = "); - } + if ( resultPreDeclare ) + writer.print(Utils.RESULT_VAR_NAME + " = "); + else if ( hasResult ) + printResultParam(type_map, writer, method, result_type, false); writer.print((alt_annotation == null ? method.getSimpleName() : alt_annotation.value()) + "("); generateCallParameters(writer, type_map, method.getParameters()); writer.print(")"); writer.println(";"); + + if ( code_annotation != null && code_annotation.nativeAfterCall().length() > 0 ) + writer.println(code_annotation.nativeAfterCall()); + generateStringDeallocations(writer, method.getParameters()); if (!result_type.equals(env.getTypeUtils().getVoidType())) { writer.print("\treturn "); Class java_result_type = Utils.getJavaType(result_type); if (Buffer.class.isAssignableFrom(java_result_type)) { - if (method.getAnnotation(CachedResult.class) != null) + if (cached_result_annotation != null) writer.print("safeNewBufferCached(env, "); else writer.print("safeNewBuffer(env, "); } else if (String.class.equals(java_result_type)) { writer.print("NewStringNativeUnsigned(env, "); - } else if ( method.getAnnotation(GLpointer.class) != null ) { + } else if ( method.getAnnotation(PointerWrapper.class) != null ) { writer.print("(intptr_t)"); } writer.print(Utils.RESULT_VAR_NAME); if (Buffer.class.isAssignableFrom(java_result_type)) { - writer.print(", "); - if (method.getAnnotation(CachedResult.class) != null && method.getAnnotation(CachedResult.class).isRange()) - Utils.printExtraCallArguments(writer, method, method.getAnnotation(AutoResultSize.class).value()); + final String size_parameter_name; + if ( auto_size_annotation != null && (auto_size_annotation.isNative() || (cached_result_annotation != null && cached_result_annotation.isRange())) ) + size_parameter_name = auto_size_annotation.value(); else - Utils.printExtraCallArguments(writer, method, Utils.RESULT_SIZE_NAME); + size_parameter_name = Utils.RESULT_SIZE_NAME; + + writer.print(", "); + Utils.printExtraCallArguments(writer, method, size_parameter_name); } if (Buffer.class.isAssignableFrom(java_result_type) || String.class.equals(java_result_type)) @@ -180,133 +199,226 @@ public class NativeMethodStubsGenerator { writer.println(); } + private static void printResultParam(final TypeMap type_map, final PrintWriter writer, final MethodDeclaration method, final TypeMirror result_type, final boolean preDeclare) { + final ParameterDeclaration result_param = Utils.getResultParameter(method); + final Declaration return_declaration = result_param == null ? method : result_param; + final NativeTypeTranslator result_translator = new NativeTypeTranslator(type_map, return_declaration); + result_type.accept(result_translator); + if ( preDeclare ) + writer.print("\t"); + writer.print(result_translator.getSignature() + " " + Utils.RESULT_VAR_NAME); + if ( preDeclare) + writer.println(";"); + else + writer.print(result_param == null ? " = " : ";\n\t"); + } + private static void generateCallParameters(PrintWriter writer, TypeMap type_map, Collection params) { if (params.size() > 0) { - Iterator it = params.iterator(); - generateCallParameter(writer, type_map, it.next()); - while (it.hasNext()) { - writer.print(", "); - generateCallParameter(writer, type_map, it.next()); + boolean first = true; + for ( ParameterDeclaration param : params ) { + if ( param.getAnnotation(Helper.class) != null ) + continue; + + if ( first ) + first = false; + else + writer.print(", "); + + generateCallParameter(writer, type_map, param); } } } private static void generateCallParameter(PrintWriter writer, TypeMap type_map, ParameterDeclaration param) { + if ( param.getAnnotation(Helper.class) != null ) + return; + + final Constant constant_annotation = param.getAnnotation(Constant.class); + if ( constant_annotation != null && constant_annotation.isNative() ) { + writer.print(constant_annotation.value()); + return; + } + boolean is_indirect = param.getAnnotation(Indirect.class) != null; - if (is_indirect || param.getAnnotation(StringList.class) != null) { + if (is_indirect || param.getAnnotation(PointerArray.class) != null) { writer.print("("); - NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param); + final NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param); param.getType().accept(translator); writer.print(translator.getSignature()); writer.print("*)"); } - if ( param.getAnnotation(GLpointer.class) != null ) - writer.print("(" + param.getAnnotation(GLpointer.class).value() + ")(intptr_t)"); + if ( param.getAnnotation(PointerWrapper.class) != null ) + writer.print("(" + param.getAnnotation(PointerWrapper.class).value() + ")(intptr_t)"); if (param.getAnnotation(Result.class) != null || is_indirect) writer.print("&"); - if (param.getAnnotation(Result.class) != null) { + + if ( param.getAnnotation(Result.class) != null ) { writer.print(Utils.RESULT_VAR_NAME); } else { writer.print(param.getSimpleName()); - if ( param.getAnnotation(StringList.class) != null ) - writer.print(STRING_LIST_POSTFIX); - else if (Utils.isAddressableType(param.getType())) + if ( param.getAnnotation(PointerArray.class) != null ) + writer.print(getPointerArrayName(Utils.getJavaType(param.getType()))); + else if ( Utils.isAddressableType(param.getType()) ) writer.print(BUFFER_ADDRESS_POSTFIX); } } private static void generateStringDeallocations(PrintWriter writer, Collection params) { for (ParameterDeclaration param : params) { - if (Utils.getJavaType(param.getType()).equals(String.class) && - param.getAnnotation(Result.class) == null) + final Class java_type = Utils.getJavaType(param.getType()); + if ( java_type.equals(String.class) && param.getAnnotation(Result.class) == null ) writer.println("\tfree(" + param.getSimpleName() + BUFFER_ADDRESS_POSTFIX + ");"); - else if (param.getAnnotation(StringList.class) != null ) // Free the string array mem - writer.println("\tfree(" + param.getSimpleName() + STRING_LIST_POSTFIX + ");"); + else if (param.getAnnotation(PointerArray.class) != null ) // Free the string array mem + writer.println("\tfree(" + param.getSimpleName() + getPointerArrayName(java_type) + ");"); } } private static void generateBufferParameterAddresses(TypeMap type_map, PrintWriter writer, MethodDeclaration method, Mode mode) { - boolean loopDeclared = false; - for (ParameterDeclaration param : method.getParameters()) - if (Utils.isAddressableType(param.getType()) && param.getAnnotation(Result.class) == null) - loopDeclared = generateBufferParameterAddress(type_map, writer, method, param, mode, loopDeclared); + strLoopDeclared = false; + ptrLoopDeclared = false; + for ( ParameterDeclaration param : method.getParameters() ) { + final Constant constant_annotation = param.getAnnotation(Constant.class); + if ( param.getAnnotation(Result.class) == null && (constant_annotation == null || !constant_annotation.isNative()) && Utils.isAddressableType(param.getType())) + generateBufferParameterAddress(type_map, writer, method, param, mode); + } } - private static boolean generateBufferParameterAddress(TypeMap type_map, PrintWriter writer, MethodDeclaration method, ParameterDeclaration param, Mode mode, boolean loopDeclared) { - NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param); + private static boolean strLoopDeclared; + private static boolean ptrLoopDeclared; + + private static void generateBufferParameterAddress(TypeMap type_map, PrintWriter writer, MethodDeclaration method, ParameterDeclaration param, Mode mode) { + final Check check_annotation = param.getAnnotation(Check.class); + final PointerArray array_annotation = param.getAnnotation(PointerArray.class); + final Class java_type = Utils.getJavaType(param.getType()); + + final NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param); param.getType().accept(translator); - writer.print("\t" + translator.getSignature() + param.getSimpleName()); - writer.print(BUFFER_ADDRESS_POSTFIX + " = (("); - writer.print(translator.getSignature()); - Check check_annotation = param.getAnnotation(Check.class); - writer.print(")"); - if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) { - writer.print("offsetToPointer(" + param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX + "))"); - } else { - Class java_type = Utils.getJavaType(param.getType()); - if (Buffer.class.isAssignableFrom(java_type) || java_type.equals(CharSequence.class) || java_type.equals(CharSequence[].class)) { - boolean explicitly_byte_sized = java_type.equals(Buffer.class) || - translator.getAnnotationType().equals(type_map.getVoidType()); - if (explicitly_byte_sized) - writer.print("(((char *)"); - if (method.getAnnotation(GenerateAutos.class) != null || (check_annotation != null && check_annotation.canBeNull())) { - writer.print("safeGetBufferAddress(env, " + param.getSimpleName()); - } else { - writer.print("(*env)->GetDirectBufferAddress(env, " + param.getSimpleName()); - } - writer.print("))"); - writer.print(" + " + param.getSimpleName() + BUFFER_POSITION_POSTFIX); - if (explicitly_byte_sized) + final String native_type = translator.getSignature(); + + if ( !java_type.isArray() || CharSequence.class.isAssignableFrom(java_type.getComponentType()) ) { + writer.print("\t" + native_type + param.getSimpleName()); + writer.print(BUFFER_ADDRESS_POSTFIX + " = (("); + writer.print(native_type); + writer.print(")"); + + if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) { + writer.print("offsetToPointer(" + param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX + "))"); + } else { + if (Buffer.class.isAssignableFrom(java_type) || java_type.equals(CharSequence.class) || java_type.equals(CharSequence[].class) || PointerBuffer.class.isAssignableFrom(java_type) ) { + boolean explicitly_byte_sized = java_type.equals(Buffer.class) || + translator.getAnnotationType().equals(type_map.getVoidType()) || + param.getAnnotation(NativeType.class) != null; + if (explicitly_byte_sized) + writer.print("(((char *)"); + if (method.getAnnotation(GenerateAutos.class) != null || (check_annotation != null && check_annotation.canBeNull())) { + writer.print("safeGetBufferAddress(env, " + param.getSimpleName()); + } else { + writer.print("(*env)->GetDirectBufferAddress(env, " + param.getSimpleName()); + } writer.print("))"); - } else if (java_type.equals(String.class)) { - writer.print("GetStringNativeChars(env, " + param.getSimpleName() + "))"); - } else - throw new RuntimeException("Illegal type " + java_type); - } - writer.println(";"); - - if ( param.getAnnotation(StringList.class) != null ) { - if ( Utils.getJavaType(param.getType()) != CharSequence[].class && ( - param.getAnnotation(GLchar.class) == null || - param.getAnnotation(NullTerminated.class) == null || - param.getAnnotation(NullTerminated.class).value().length() == 0 - ) - ) - throw new RuntimeException("StringList annotation can only be applied on null-terminated GLchar buffers."); - - if ( "_str".equals(param.getSimpleName()) ) - throw new RuntimeException("The name '_str' is not valid for arguments annotated with StringList"); - - // Declare loop counters and allocate string array - if ( !loopDeclared ) { - writer.println("\tunsigned int _str_i;"); - writer.println("\tGLchar *_str_address;"); - loopDeclared = true; + writer.print(" + " + param.getSimpleName() + BUFFER_POSITION_POSTFIX); + if (explicitly_byte_sized) + writer.print("))"); + } else if (java_type.equals(String.class)) { + writer.print("GetStringNativeChars(env, " + param.getSimpleName() + "))"); + } else if ( array_annotation == null ) + throw new RuntimeException("Illegal type " + java_type); } - writer.println("\tGLchar **" + param.getSimpleName() + STRING_LIST_POSTFIX + " = (GLchar **) malloc(" + param.getAnnotation(StringList.class).value() + "*sizeof(GLchar*));"); + writer.println(";"); + } + + if ( array_annotation != null ) { + final String n = getPointerArrayName(java_type); + final String arrayType; + if ( POINTER_LIST_NAME.equals(n) ) { + if ( n.equals(param.getSimpleName()) ) + throw new RuntimeException("The name '" + n + "' is not valid for object array arguments annotated with PointerArray"); + + arrayType = translator.getSignature(true) + (org.lwjgl.PointerWrapper.class.isAssignableFrom(java_type.getComponentType()) ? " " : ""); + + // Declare loop counters and allocate object array + if ( !ptrLoopDeclared ) { + writer.println("\tunsigned int " + n + "_i;"); + writer.println("\tjobject " + n + "_object;"); + ptrLoopDeclared = true; + } + } else { + if ( n.equals(param.getSimpleName()) ) + throw new RuntimeException("The name '" + n + "' is not valid for arguments annotated with PointerArray"); + + arrayType = translator.getSignature(true); + + // Declare loop counters and allocate string array + if ( !strLoopDeclared ) { + writer.println("\tunsigned int " + n + "_i;"); + writer.println("\t" + arrayType + n + "_address;"); + strLoopDeclared = true; + } + } + + writer.print("\t" + arrayType + "*" + param.getSimpleName() + n + " = "); + if ( check_annotation != null && check_annotation.canBeNull() ) + writer.print(array_annotation.value() + " == 0 ? NULL : "); + writer.println("(" + arrayType + "*) malloc(" + array_annotation.value() + " * sizeof(" + arrayType + "));"); } - return loopDeclared; } - private static void generateStringListInits(PrintWriter writer, Collection params) { - for ( ParameterDeclaration param : params ) { - StringList stringList_annotation = param.getAnnotation(StringList.class); - if ( stringList_annotation != null ) { - String lengths = stringList_annotation.lengths(); + private static String getPointerArrayName(final Class java_type) { + final Class component_type = java_type.getComponentType(); + if ( component_type != null && (Buffer.class.isAssignableFrom(component_type) || org.lwjgl.PointerWrapper.class.isAssignableFrom(component_type)) ) + return POINTER_LIST_NAME; + else + return STRING_LIST_NAME; + } - // Init vars - writer.println("\t_str_i = 0;"); - writer.println("\t_str_address = (GLchar *)" + param.getSimpleName() + BUFFER_ADDRESS_POSTFIX + ";"); - // Fill string array with the string pointers - writer.println("\twhile ( _str_i < " + stringList_annotation.value() + " ) {"); - if ( lengths.length() == 0 ) { - writer.println("\t\t" + param.getSimpleName() + STRING_LIST_POSTFIX + "[_str_i++] = _str_address;"); - writer.println("\t\t_str_address += strlen(_str_address) + 1;"); + private static boolean hasPointerArrayInits(Collection params) { + for ( ParameterDeclaration param : params ) { + PointerArray pointerArray_annotation = param.getAnnotation(PointerArray.class); + if ( pointerArray_annotation != null ) + return true; + } + return false; + } + + private static void generatePointerArrayInits(TypeMap type_map, PrintWriter writer, Collection params) { + for ( ParameterDeclaration param : params ) { + PointerArray pointerArray_annotation = param.getAnnotation(PointerArray.class); + if ( pointerArray_annotation != null ) { + final Class java_type = Utils.getJavaType(param.getType()); + final Class component_type = java_type.isArray() ? java_type.getComponentType() : null; + final NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param); + param.getType().accept(translator); + + final String n = getPointerArrayName(java_type); + if ( POINTER_LIST_NAME.equals(n) ) { + // Init vars + writer.println("\t" + n + "_i = 0;"); + // Fill pointer array with the buffer pointers + writer.println("\twhile ( " + n + "_i < " + pointerArray_annotation.value() + " ) {"); + if ( component_type.isAssignableFrom(Buffer.class) ) + writer.println("\t\t" + n + "_object = (*env)->GetObjectArrayElement(env, " + param.getSimpleName() + ", " + n + "_i);"); + else + writer.println("\t\t" + n + "_object = (*env)->GetObjectArrayElement(env, " + param.getSimpleName() + ", " + n + "_i);"); + writer.println("\t\t" + param.getSimpleName() + n + "[" + n + "_i++] = (" + translator.getSignature(true) + ")(intptr_t)getPointerWrapperAddress(env, " + n + "_object);"); + writer.println("\t}"); } else { - writer.println("\t\t" + param.getSimpleName() + STRING_LIST_POSTFIX + "[_str_i] = _str_address;"); - writer.println("\t\t_str_address += " + lengths + BUFFER_ADDRESS_POSTFIX + "[_str_i++];"); + final String lengths = pointerArray_annotation.lengths(); + + // Init vars + writer.println("\t" + n + "_i = 0;"); + writer.println("\t" + n + "_address = (" + translator.getSignature(true) + ")" + param.getSimpleName() + BUFFER_ADDRESS_POSTFIX + ";"); + // Fill string array with the string pointers + writer.println("\twhile ( " + n + "_i < " + pointerArray_annotation.value() + " ) {"); + if ( lengths.length() == 0 ) { + writer.println("\t\t" + param.getSimpleName() + n + "[" + n + "_i++] = " + n + "_address;"); + writer.println("\t\t" + n + "_address += strlen(" + n + "_address) + 1;"); + } else { + writer.println("\t\t" + param.getSimpleName() + n + "[" + n + "_i] = " + n + "_address;"); + writer.println("\t\t" + n + "_address += " + lengths + BUFFER_ADDRESS_POSTFIX + "[" + n + "_i++];"); + } + writer.println("\t}"); } - writer.println("\t}"); } } } diff --git a/src/java/org/lwjgl/util/generator/NativeType.java b/src/java/org/lwjgl/util/generator/NativeType.java index d37187c1..5c7d1ccb 100644 --- a/src/java/org/lwjgl/util/generator/NativeType.java +++ b/src/java/org/lwjgl/util/generator/NativeType.java @@ -44,6 +44,7 @@ package org.lwjgl.util.generator; import java.lang.annotation.Target; import java.lang.annotation.ElementType; -@Target(ElementType.ANNOTATION_TYPE) +@Target({ElementType.ANNOTATION_TYPE, ElementType.PARAMETER}) public @interface NativeType { + String value() default ""; } diff --git a/src/java/org/lwjgl/util/generator/NativeTypeTranslator.java b/src/java/org/lwjgl/util/generator/NativeTypeTranslator.java index f751d02f..a053a03b 100644 --- a/src/java/org/lwjgl/util/generator/NativeTypeTranslator.java +++ b/src/java/org/lwjgl/util/generator/NativeTypeTranslator.java @@ -42,22 +42,21 @@ package org.lwjgl.util.generator; * $Id$ */ -import org.lwjgl.opengl.PointerWrapper; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.ArrayList; - -import java.nio.*; +import org.lwjgl.PointerBuffer; import java.lang.annotation.Annotation; +import java.nio.*; +import java.util.ArrayList; +import java.util.Collection; + +import com.sun.mirror.declaration.AnnotationMirror; +import com.sun.mirror.declaration.Declaration; +import com.sun.mirror.type.*; +import com.sun.mirror.util.TypeVisitor; /** * $Id$ - * + *

* A TypeVisitor that translates (annotated) TypeMirrors to * native types * @@ -65,6 +64,7 @@ import java.lang.annotation.Annotation; * @version $Revision$ */ public class NativeTypeTranslator implements TypeVisitor { + private Collection native_types; private boolean is_indirect; private final Declaration declaration; @@ -76,26 +76,32 @@ public class NativeTypeTranslator implements TypeVisitor { } public String getSignature() { + return getSignature(false); + } + + public String getSignature(final boolean skipConst) { StringBuilder signature = new StringBuilder(); - if (declaration.getAnnotation(Const.class) != null) + if ( !skipConst && declaration.getAnnotation(Const.class) != null ) signature.append("const "); - if ( declaration.getAnnotation(GLpointer.class) != null ) { - signature.append(declaration.getAnnotation(GLpointer.class).value()); + if ( declaration.getAnnotation(PointerWrapper.class) != null ) { + signature.append(declaration.getAnnotation(PointerWrapper.class).value()); + } else if ( declaration.getAnnotation(NativeType.class) != null ) { + signature.append(declaration.getAnnotation(NativeType.class).value()); } else { // Use the name of the native type annotation as the C type name signature.append(getAnnotationType().getSimpleName()); } - if (is_indirect) + if ( is_indirect ) signature.append(" *"); return signature.toString(); } public Class getAnnotationType() { - if (native_types.size() != 1) + if ( native_types.size() != 1 ) throw new RuntimeException("Expected only one native type for declaration " + declaration + - ", but got " + native_types.size()); + ", but got " + native_types.size()); return native_types.iterator().next(); } @@ -104,34 +110,43 @@ public class NativeTypeTranslator implements TypeVisitor { } public void visitArrayType(ArrayType t) { - if ( "java.lang.CharSequence".equals(t.getComponentType().toString()) ) { + final Class type = Utils.getJavaType(t).getComponentType(); + + if ( CharSequence.class.isAssignableFrom(type) ) { is_indirect = true; native_types = new ArrayList(); - native_types.add(GLchar.class); + native_types.add(type_map.getStringArrayType()); + } else if ( Buffer.class.isAssignableFrom(type) ) { + is_indirect = true; + native_types = new ArrayList(); + native_types.add(type_map.getByteBufferArrayType()); + } else if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(type) ) { + is_indirect = false; } else throw new RuntimeException(t + " is not allowed"); } public static PrimitiveType.Kind getPrimitiveKindFromBufferClass(Class c) { - if (IntBuffer.class.equals(c)) + if ( IntBuffer.class.equals(c) ) return PrimitiveType.Kind.INT; - else if (DoubleBuffer.class.equals(c)) + else if ( DoubleBuffer.class.equals(c) ) return PrimitiveType.Kind.DOUBLE; - else if (ShortBuffer.class.equals(c)) + else if ( ShortBuffer.class.equals(c) ) return PrimitiveType.Kind.SHORT; - else if (ByteBuffer.class.equals(c)) + else if ( ByteBuffer.class.equals(c) || PointerBuffer.class.equals(c) ) return PrimitiveType.Kind.BYTE; - else if (FloatBuffer.class.equals(c)) + else if ( FloatBuffer.class.equals(c) ) return PrimitiveType.Kind.FLOAT; - else if (LongBuffer.class.equals(c)) + else if ( LongBuffer.class.equals(c) ) return PrimitiveType.Kind.LONG; else throw new RuntimeException(c + " is not allowed"); } - public static Class getClassFromType(DeclaredType t) { + @SuppressWarnings("unchecked") + public static Class getClassFromType(DeclaredType t) { try { - return Class.forName(t.getDeclaration().getQualifiedName()); + return (Class)Class.forName(t.getDeclaration().getQualifiedName()); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } @@ -139,7 +154,7 @@ public class NativeTypeTranslator implements TypeVisitor { private void getNativeTypeFromAnnotatedPrimitiveType(PrimitiveType.Kind kind) { native_types = translateAnnotations(); - if (native_types.size() == 0) + if ( native_types.size() == 0 ) native_types.add(type_map.getNativeTypeFromPrimitiveType(kind)); } @@ -147,18 +162,21 @@ public class NativeTypeTranslator implements TypeVisitor { is_indirect = true; Class c = getClassFromType(t); - if (String.class.equals(c)) { + if ( String.class.equals(c) ) { native_types = new ArrayList(); native_types.add(type_map.getStringElementType()); - } else if (Buffer.class.equals(c)) { + } else if ( Buffer.class.equals(c) ) { native_types = new ArrayList(); native_types.add(type_map.getVoidType()); - } else if (Buffer.class.isAssignableFrom(c)) { + } else if ( Buffer.class.isAssignableFrom(c) ) { PrimitiveType.Kind kind = getPrimitiveKindFromBufferClass(c); getNativeTypeFromAnnotatedPrimitiveType(kind); - } else if ( PointerWrapper.class.isAssignableFrom(c) ) { + } else if ( PointerBuffer.class.isAssignableFrom(c) ) { native_types = new ArrayList(); - native_types.add(GLpointer.class); + native_types.add(PointerBuffer.class); + } else if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(c) ) { + native_types = new ArrayList(); + native_types.add(PointerWrapper.class); is_indirect = false; } else @@ -182,13 +200,14 @@ public class NativeTypeTranslator implements TypeVisitor { } // Check if the annotation is itself annotated with a certain annotation type + public static T getAnnotation(AnnotationMirror annotation, Class type) { return annotation.getAnnotationType().getDeclaration().getAnnotation(type); } private static Class translateAnnotation(AnnotationMirror annotation) { NativeType native_type = getAnnotation(annotation, NativeType.class); - if (native_type != null) { + if ( native_type != null ) { return getClassFromType(annotation.getAnnotationType()); } else return null; @@ -196,9 +215,9 @@ public class NativeTypeTranslator implements TypeVisitor { private Collection translateAnnotations() { Collection result = new ArrayList(); - for (AnnotationMirror annotation : Utils.getSortedAnnotations(declaration.getAnnotationMirrors())) { + for ( AnnotationMirror annotation : Utils.getSortedAnnotations(declaration.getAnnotationMirrors()) ) { Class translated_result = translateAnnotation(annotation); - if (translated_result != null) { + if ( translated_result != null ) { result.add(translated_result); } } @@ -219,7 +238,7 @@ public class NativeTypeTranslator implements TypeVisitor { public void visitVoidType(VoidType t) { native_types = translateAnnotations(); - if (native_types.size() == 0) + if ( native_types.size() == 0 ) native_types.add(void.class); } diff --git a/src/java/org/lwjgl/util/generator/StringList.java b/src/java/org/lwjgl/util/generator/PointerArray.java similarity index 96% rename from src/java/org/lwjgl/util/generator/StringList.java rename to src/java/org/lwjgl/util/generator/PointerArray.java index 0d9e20da..0eaa4939 100644 --- a/src/java/org/lwjgl/util/generator/StringList.java +++ b/src/java/org/lwjgl/util/generator/PointerArray.java @@ -40,7 +40,7 @@ import java.lang.annotation.ElementType; import java.lang.annotation.Target; @Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface StringList { +public @interface PointerArray { /** Number of values in the string list (name of native-side parameter) */ String value(); /** List of string lengths (name of native-side parameter) */ diff --git a/src/java/org/lwjgl/util/generator/GLpointer.java b/src/java/org/lwjgl/util/generator/PointerWrapper.java similarity index 87% rename from src/java/org/lwjgl/util/generator/GLpointer.java rename to src/java/org/lwjgl/util/generator/PointerWrapper.java index ef77e874..0efe2259 100644 --- a/src/java/org/lwjgl/util/generator/GLpointer.java +++ b/src/java/org/lwjgl/util/generator/PointerWrapper.java @@ -38,7 +38,9 @@ import java.lang.annotation.Target; import java.lang.annotation.ElementType; @Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLpointer { +public @interface PointerWrapper { String value(); // The native pointer type. boolean canBeNull() default false; // Whether the pointer may be null. + String params() default ""; // Pass these extra parameters when constructing PointerWrapper objects. + String factory() default ""; // Use this factory method call instead of normal object construction. } \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/PostfixTranslator.java b/src/java/org/lwjgl/util/generator/PostfixTranslator.java index 6603a55a..8e76e70d 100644 --- a/src/java/org/lwjgl/util/generator/PostfixTranslator.java +++ b/src/java/org/lwjgl/util/generator/PostfixTranslator.java @@ -46,6 +46,7 @@ import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import com.sun.mirror.util.*; +import java.lang.annotation.Annotation; import java.nio.*; public class PostfixTranslator implements TypeVisitor { @@ -108,7 +109,7 @@ public class PostfixTranslator implements TypeVisitor { private boolean translateAnnotation(AnnotationMirror annotation) { NativeType native_type = NativeTypeTranslator.getAnnotation(annotation, NativeType.class); if (native_type != null) { - Class annotation_class = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType()); + Class annotation_class = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType()); signature.append(type_map.translateAnnotation(annotation_class)); return true; } else diff --git a/src/java/org/lwjgl/util/generator/Private.java b/src/java/org/lwjgl/util/generator/Private.java new file mode 100644 index 00000000..3cfcc12e --- /dev/null +++ b/src/java/org/lwjgl/util/generator/Private.java @@ -0,0 +1,46 @@ +/* + * 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.util.generator; + +/** + * Extension templates marked with @Private will result in classes without the public keyword. + * + * @author Spasi + */ + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target({ElementType.TYPE, ElementType.METHOD}) +public @interface Private { + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/RegisterStubsGenerator.java b/src/java/org/lwjgl/util/generator/RegisterStubsGenerator.java index 0f4d4c30..bdd3299d 100644 --- a/src/java/org/lwjgl/util/generator/RegisterStubsGenerator.java +++ b/src/java/org/lwjgl/util/generator/RegisterStubsGenerator.java @@ -41,6 +41,8 @@ package org.lwjgl.util.generator; * $Id$ */ +import org.lwjgl.opencl.CLMem; + import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; @@ -52,7 +54,8 @@ public class RegisterStubsGenerator { Iterator it = d.getMethods().iterator(); while (it.hasNext()) { MethodDeclaration method = it.next(); - if ( method.getAnnotation(Alternate.class) != null ) + Alternate alt_annotation = method.getAnnotation(Alternate.class); + if ( (alt_annotation != null && (!alt_annotation.nativeAlt() || alt_annotation.skipNative())) || method.getAnnotation(Reuse.class) != null ) continue; EnumSet platforms; PlatformDependent platform_annotation = method.getAnnotation(PlatformDependent.class); @@ -83,20 +86,30 @@ public class RegisterStubsGenerator { Collection params = method.getParameters(); String signature = "("; for (ParameterDeclaration param : params) { - if (param.getAnnotation(Result.class) != null) + if ( param.getAnnotation(Helper.class) != null || param.getAnnotation(Result.class) != null ) continue; - if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) { + + final Constant constant_annotation = param.getAnnotation(Constant.class); + if ( constant_annotation != null && constant_annotation.isNative() ) + continue; + + if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) signature += "I"; - } else { + else signature += getTypeSignature(param.getType(), true); - } } - TypeMirror result_type = Utils.getMethodReturnType(method); - if (Utils.getNIOBufferType(result_type) != null) - signature += "I"; + + final TypeMirror result_type = Utils.getMethodReturnType(method); + final CachedResult cached_result_annotation = method.getAnnotation(CachedResult.class); + final AutoSize auto_size_annotation = method.getAnnotation(AutoSize.class); + + if ( Utils.getNIOBufferType(result_type) != null && (auto_size_annotation == null || !auto_size_annotation.isNative()) ) + signature += "J"; + String result_type_signature = getTypeSignature(result_type, false); - if (method.getAnnotation(CachedResult.class) != null) + if ( cached_result_annotation != null ) signature += result_type_signature; + signature += ")"; signature += result_type_signature; return signature; @@ -110,8 +123,11 @@ public class RegisterStubsGenerator { writer.print(Utils.getQualifiedNativeMethodName(Utils.getQualifiedClassName(d), method, generate_error_checks, context_specific)); if (mode == Mode.BUFFEROBJECT) writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX); - String opengl_handle_name = method.getSimpleName().replaceFirst("gl", platform.getPrefix()); - writer.print(", \"" + opengl_handle_name + "\", (void *)&" + method.getSimpleName() + "}"); + + final Alternate alt_annotation = method.getAnnotation(Alternate.class); + final String methodName = alt_annotation == null ? method.getSimpleName() : alt_annotation.value(); + String opengl_handle_name = methodName.replaceFirst("gl", platform.getPrefix()); + writer.print(", \"" + opengl_handle_name + "\", (void *)&" + methodName + "}"); if (has_more) writer.println(","); } diff --git a/src/java/org/lwjgl/util/generator/Reuse.java b/src/java/org/lwjgl/util/generator/Reuse.java new file mode 100644 index 00000000..63f1ae58 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/Reuse.java @@ -0,0 +1,49 @@ +/* + * 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 + * 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.generator; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +/** + * Reuse can be used to annotate methods that duplicate functionality that has been already + * defined somewhere else. For example, this can be applied to OpenGL core functionality that + * exists as an ARB extension as well, but with the exact same entry points. + * + * @author Spasi + */ +@Target(ElementType.METHOD) +public @interface Reuse { + /** The extension Class that defines the method. */ + String value(); + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/SignatureTranslator.java b/src/java/org/lwjgl/util/generator/SignatureTranslator.java index dcf178ba..e07ee7bb 100644 --- a/src/java/org/lwjgl/util/generator/SignatureTranslator.java +++ b/src/java/org/lwjgl/util/generator/SignatureTranslator.java @@ -41,6 +41,8 @@ package org.lwjgl.util.generator; * $Id$ */ +import org.lwjgl.PointerBuffer; + import com.sun.mirror.type.*; import com.sun.mirror.util.*; @@ -67,17 +69,33 @@ class SignatureTranslator implements TypeVisitor { } public void visitArrayType(ArrayType t) { - throw new RuntimeException(t + " is not allowed"); + final Class type = Utils.getJavaType(t.getComponentType()); + if ( CharSequence.class.isAssignableFrom(type) ) + signature.append("Ljava/nio/ByteBuffer;I"); + else if ( Buffer.class.isAssignableFrom(type) ) + signature.append("[Ljava/nio/ByteBuffer;"); + else if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(type) ) + signature.append("[L" + getNativeNameFromClassName(type.getName()) + ";"); + else + throw new RuntimeException(t + " is not allowed"); } public void visitClassType(ClassType t) { - String type_name = getNativeNameFromClassName(t.getDeclaration().getQualifiedName()); + Class type = NativeTypeTranslator.getClassFromType(t); + String type_name; + if ( CharSequence.class.isAssignableFrom(type) || CharSequence[].class.isAssignableFrom(type) || PointerBuffer.class.isAssignableFrom(type) ) + type_name = ByteBuffer.class.getName(); + else if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(type) ) { + signature.append("J"); + return; + } else + type_name = t.getDeclaration().getQualifiedName(); + signature.append("L"); - signature.append(type_name); + signature.append(getNativeNameFromClassName(type_name)); signature.append(";"); - if (add_position_signature && Buffer.class.isAssignableFrom(NativeTypeTranslator.getClassFromType(t))) { + if ( add_position_signature && Utils.isAddressableType(type) ) signature.append("I"); - } } public void visitDeclaredType(DeclaredType t) { diff --git a/src/java/org/lwjgl/util/generator/TypeInfo.java b/src/java/org/lwjgl/util/generator/TypeInfo.java index 21093e11..eccf57db 100644 --- a/src/java/org/lwjgl/util/generator/TypeInfo.java +++ b/src/java/org/lwjgl/util/generator/TypeInfo.java @@ -41,9 +41,12 @@ package org.lwjgl.util.generator; * $Id$ */ +import org.lwjgl.util.generator.opengl.GLvoid; + import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; +import java.lang.annotation.Annotation; import java.util.*; import java.nio.*; @@ -95,6 +98,9 @@ public class TypeInfo { case BYTE: type = byte.class; break; + case BOOLEAN: + type = boolean.class; + break; default: throw new RuntimeException(kind + " is not allowed"); } @@ -151,7 +157,7 @@ public class TypeInfo { for (AnnotationMirror annotation : annotations) { NativeType native_type_annotation = NativeTypeTranslator.getAnnotation(annotation, NativeType.class); if (native_type_annotation != null) { - Class annotation_type = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType()); + Class annotation_type = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType()); Signedness signedness = type_map.getSignednessFromType(annotation_type); Class inverse_type = type_map.getInverseType(annotation_type); String auto_type = type_map.getAutoTypeFromAnnotation(annotation); diff --git a/src/java/org/lwjgl/util/generator/TypeMap.java b/src/java/org/lwjgl/util/generator/TypeMap.java index 8db38643..d70bc3ee 100644 --- a/src/java/org/lwjgl/util/generator/TypeMap.java +++ b/src/java/org/lwjgl/util/generator/TypeMap.java @@ -45,19 +45,25 @@ import com.sun.mirror.declaration.*; import com.sun.mirror.type.*; import java.io.*; +import java.lang.annotation.Annotation; public interface TypeMap { - String getErrorCheckMethodName(); + void printCapabilitiesInit(PrintWriter writer); + String getCapabilities(); + void printErrorCheckMethod(PrintWriter writer, MethodDeclaration method, String tabs); String getRegisterNativesFunctionName(); - PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type); - String getTypedefPrefix(); + PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type); + String getTypedefPostfix(); + String getFunctionPrefix(); void printNativeIncludes(PrintWriter writer); - Class getStringElementType(); + Class getStringElementType(); + Class getStringArrayType(); + Class getByteBufferArrayType(); Class[] getValidAnnotationTypes(Class type); - Class getVoidType(); - String translateAnnotation(Class annotation_type); + Class getVoidType(); + String translateAnnotation(Class annotation_type); Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind); String getAutoTypeFromAnnotation(AnnotationMirror annotation); - Class getInverseType(Class type); - Signedness getSignednessFromType(Class type); + Class getInverseType(Class type); + Signedness getSignednessFromType(Class type); } diff --git a/src/java/org/lwjgl/util/generator/TypedefsGenerator.java b/src/java/org/lwjgl/util/generator/TypedefsGenerator.java index 2096a9fd..af1c7db5 100644 --- a/src/java/org/lwjgl/util/generator/TypedefsGenerator.java +++ b/src/java/org/lwjgl/util/generator/TypedefsGenerator.java @@ -51,11 +51,12 @@ public class TypedefsGenerator { private static void generateNativeTypedefs(TypeMap type_map, PrintWriter writer, MethodDeclaration method) { TypeMirror return_type = method.getReturnType(); writer.print("typedef "); + writer.print(type_map.getTypedefPostfix()); NativeTypeTranslator translator = new NativeTypeTranslator(type_map, method); return_type.accept(translator); writer.print(translator.getSignature()); writer.print(" ("); - writer.print(type_map.getTypedefPrefix()); + writer.print(type_map.getFunctionPrefix()); writer.print(" *" + Utils.getTypedefName(method) + ") ("); generateNativeTypedefsParameters(type_map, writer, method.getParameters()); writer.println(");"); @@ -63,11 +64,17 @@ public class TypedefsGenerator { private static void generateNativeTypedefsParameters(TypeMap type_map, PrintWriter writer, Collection params) { if (params.size() > 0) { - Iterator it = params.iterator(); - generateNativeTypedefsParameter(type_map, writer, it.next()); - while (it.hasNext()) { - writer.print(", "); - generateNativeTypedefsParameter(type_map, writer, it.next()); + boolean first = true; + for ( ParameterDeclaration param : params ) { + if ( param.getAnnotation(Helper.class) != null ) + continue; + + if ( first ) + first = false; + else + writer.print(", "); + + generateNativeTypedefsParameter(type_map, writer, param); } } } @@ -76,14 +83,14 @@ public class TypedefsGenerator { NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param); param.getType().accept(translator); writer.print(translator.getSignature()); - if (param.getAnnotation(Result.class) != null || param.getAnnotation(Indirect.class) != null || param.getAnnotation(StringList.class) != null) + if (param.getAnnotation(Result.class) != null || param.getAnnotation(Indirect.class) != null || param.getAnnotation(PointerArray.class) != null) writer.print("*"); writer.print(" " + param.getSimpleName()); } public static void generateNativeTypedefs(TypeMap type_map, PrintWriter writer, Collection methods) { for (MethodDeclaration method : methods) { - if ( method.getAnnotation(Alternate.class) == null ) + if ( method.getAnnotation(Alternate.class) == null && method.getAnnotation(Reuse.class) == null ) generateNativeTypedefs(type_map, writer, method); } } diff --git a/src/java/org/lwjgl/util/generator/Utils.java b/src/java/org/lwjgl/util/generator/Utils.java index 34066f05..45610136 100644 --- a/src/java/org/lwjgl/util/generator/Utils.java +++ b/src/java/org/lwjgl/util/generator/Utils.java @@ -40,6 +40,12 @@ package org.lwjgl.util.generator; * $Id$ */ +import org.lwjgl.PointerBuffer; +import org.lwjgl.util.generator.opengl.GLboolean; +import org.lwjgl.util.generator.opengl.GLchar; +import org.lwjgl.util.generator.opengl.GLcharARB; +import org.lwjgl.util.generator.opengl.GLreturn; + import java.io.PrintWriter; import java.nio.Buffer; import java.nio.ByteBuffer; @@ -75,11 +81,19 @@ public class Utils { } public static String getFunctionAddressName(InterfaceDeclaration interface_decl, MethodDeclaration method, boolean forceAlt) { - Alternate alt_annotation = method.getAnnotation(Alternate.class); + final Alternate alt_annotation = method.getAnnotation(Alternate.class); + + /* Removed prefix so that we can identify reusable entry points, removed postfix because it's not needed and looks nicer. + String interfaceName = interface_decl.getSimpleName(); // If we add this back, we need to fix @Reuse (add a param for the template name) if ( alt_annotation == null || (alt_annotation.nativeAlt() && !forceAlt) ) - return interface_decl.getSimpleName() + "_" + method.getSimpleName() + FUNCTION_POINTER_POSTFIX; + return interfaceName + "_" + method.getSimpleName() + FUNCTION_POINTER_POSTFIX; else - return interface_decl.getSimpleName() + "_" + alt_annotation.value() + FUNCTION_POINTER_POSTFIX; + return interfaceName + "_" + alt_annotation.value() + FUNCTION_POINTER_POSTFIX; + */ + if ( alt_annotation == null || (alt_annotation.nativeAlt() && !forceAlt) ) + return method.getSimpleName(); + else + return alt_annotation.value(); } public static boolean isFinal(InterfaceDeclaration d) { @@ -115,7 +129,15 @@ public class Utils { } public static boolean isAddressableType(Class type) { - return Buffer.class.isAssignableFrom(type) || String.class.equals(type) || CharSequence.class.equals(type) || CharSequence[].class.equals(type); + if ( type.isArray() ) { + final Class component_type = type.getComponentType(); + return isAddressableTypeImpl(component_type) || org.lwjgl.PointerWrapper.class.isAssignableFrom(component_type); + } + return isAddressableTypeImpl(type); + } + + private static boolean isAddressableTypeImpl(Class type) { + return Buffer.class.isAssignableFrom(type) || PointerBuffer.class.isAssignableFrom(type) || CharSequence.class.isAssignableFrom(type); } public static Class getJavaType(TypeMirror type_mirror) { @@ -149,11 +171,23 @@ public class Utils { public static void printDocComment(PrintWriter writer, Declaration decl) { String doc_comment = decl.getDocComment(); if (doc_comment != null) { - String tab = decl instanceof InterfaceDeclaration ? "" : "\t"; + final String tab = decl instanceof InterfaceDeclaration ? "" : "\t"; writer.println(tab + "/**"); - StringTokenizer doc_lines = new StringTokenizer(doc_comment, "\n"); - while (doc_lines.hasMoreTokens()) - writer.println(tab + " * " + doc_lines.nextToken()); + + final StringTokenizer doc_lines = new StringTokenizer(doc_comment, "\n", true); + boolean lastWasNL = false; + while (doc_lines.hasMoreTokens()) { + final String t = doc_lines.nextToken(); + if ( "\n".equals(t) ) { + if ( lastWasNL ) + writer.println(tab + " *"); + lastWasNL = true; + } else { + writer.println(tab + " * " + t); + lastWasNL = false; + } + } + writer.println(tab + " */"); } else if ( (decl instanceof MethodDeclaration) && decl.getAnnotation(Alternate.class) != null ) writer.println("\t/** Overloads " + decl.getAnnotation(Alternate.class).value() + " */"); @@ -241,7 +275,7 @@ public class Utils { } public static boolean needResultSize(MethodDeclaration method) { - return getNIOBufferType(getMethodReturnType(method)) != null && method.getAnnotation(AutoResultSize.class) == null; + return getNIOBufferType(getMethodReturnType(method)) != null && method.getAnnotation(AutoSize.class) == null; } public static void printExtraCallArguments(PrintWriter writer, MethodDeclaration method, String size_parameter_name) { @@ -289,7 +323,7 @@ public class Utils { Class param_type = getJavaType(t); if (Buffer.class.isAssignableFrom(param_type)) return param_type; - else if ( param_type == CharSequence.class || param_type == CharSequence[].class ) + else if ( param_type == CharSequence.class || param_type == CharSequence[].class || param_type == PointerBuffer.class ) return ByteBuffer.class; else return null; @@ -337,9 +371,9 @@ public class Utils { } else if ( type.equals(CharSequence[].class) ) { if ( offset == null ) - offset = "APIUtils.getTotalLength(" + p.getSimpleName() + ")"; + offset = "APIUtil.getTotalLength(" + p.getSimpleName() + ")"; else - offset += " + APIUtils.getTotalLength(" + p.getSimpleName() + ")"; + offset += " + APIUtil.getTotalLength(" + p.getSimpleName() + ")"; if ( p.getAnnotation(NullTerminated.class) != null ) offset += " + " + p.getSimpleName() + ".length"; } @@ -352,10 +386,10 @@ public class Utils { if ( "String".equals(return_type) ) { if ( !return_annotation.forceMaxLength() ) { - writer.println("IntBuffer " + return_annotation.value() + "_length = APIUtils.getLengths();"); + writer.println("IntBuffer " + return_annotation.value() + "_length = APIUtil.getLengths();"); writer.print("\t\t"); } - writer.print("ByteBuffer " + return_annotation.value() + " = APIUtils.getBufferByte(" + return_annotation.maxLength()); + writer.print("ByteBuffer " + return_annotation.value() + " = APIUtil.getBufferByte(" + 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 @@ -367,13 +401,18 @@ public class Utils { writer.println(");"); } else { final String buffer_type = "Boolean".equals(return_type) ? "Byte" : return_type; - writer.print(buffer_type + "Buffer " + return_annotation.value() + " = APIUtils.getBuffer" + buffer_type + "("); + writer.print(buffer_type + "Buffer " + return_annotation.value() + " = APIUtil.getBuffer" + buffer_type + "("); if ( "Byte".equals(buffer_type) ) writer.print('1'); writer.println(");"); } - writer.print("\t\t"); + final Code code_annotation = method.getAnnotation(Code.class); + if ( code_annotation != null && code_annotation.tryBlock() ) { + writer.println("\t\ttry {"); + writer.print("\t\t\t"); + } else + writer.print("\t\t"); } static void printGLReturnPost(PrintWriter writer, MethodDeclaration method, GLreturn return_annotation) { @@ -389,7 +428,7 @@ public class Utils { else writer.print(return_annotation.value() + "_length.get(0)"); writer.println(");"); - writer.println("\t\treturn APIUtils.getString(" + return_annotation.value() + ");"); + writer.println("\t\treturn APIUtil.getString(" + return_annotation.value() + ");"); } else { writer.print("\t\treturn " + return_annotation.value() + ".get(0)"); if ( "Boolean".equals(return_type) ) diff --git a/src/java/org/lwjgl/util/generator/ALTypeMap.java b/src/java/org/lwjgl/util/generator/openal/ALTypeMap.java similarity index 83% rename from src/java/org/lwjgl/util/generator/ALTypeMap.java rename to src/java/org/lwjgl/util/generator/openal/ALTypeMap.java index 8e379fd6..d5c32da9 100644 --- a/src/java/org/lwjgl/util/generator/ALTypeMap.java +++ b/src/java/org/lwjgl/util/generator/openal/ALTypeMap.java @@ -1,218 +1,242 @@ -/* - * 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 - * 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.generator; - -/** - * - * The OpenAL specific generator behaviour - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; - -import java.io.*; -import java.util.*; -import java.nio.*; - -public class ALTypeMap implements TypeMap { - private static final Map native_types_to_primitive; - - static { - native_types_to_primitive = new HashMap(); - native_types_to_primitive.put(ALboolean.class, PrimitiveType.Kind.BOOLEAN); - native_types_to_primitive.put(ALbyte.class, PrimitiveType.Kind.BYTE); - native_types_to_primitive.put(ALenum.class, PrimitiveType.Kind.INT); - native_types_to_primitive.put(ALfloat.class, PrimitiveType.Kind.FLOAT); - native_types_to_primitive.put(ALdouble.class, PrimitiveType.Kind.DOUBLE); - native_types_to_primitive.put(ALint.class, PrimitiveType.Kind.INT); - native_types_to_primitive.put(ALshort.class, PrimitiveType.Kind.SHORT); - native_types_to_primitive.put(ALsizei.class, PrimitiveType.Kind.INT); - native_types_to_primitive.put(ALubyte.class, PrimitiveType.Kind.BYTE); - native_types_to_primitive.put(ALuint.class, PrimitiveType.Kind.INT); - native_types_to_primitive.put(ALvoid.class, PrimitiveType.Kind.BYTE); - } - - public PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type) { - PrimitiveType.Kind kind = native_types_to_primitive.get(native_type); - if (kind == null) - throw new RuntimeException("Unsupported type " + native_type); - return kind; - } - - public Signedness getSignednessFromType(Class type) { - if (ALuint.class.equals(type)) - return Signedness.UNSIGNED; - else if (ALint.class.equals(type)) - return Signedness.SIGNED; - else if (ALshort.class.equals(type)) - return Signedness.SIGNED; - else if (ALbyte.class.equals(type)) - return Signedness.SIGNED; - else - return Signedness.NONE; - } - - public String translateAnnotation(Class annotation_type) { - if (annotation_type.equals(ALuint.class)) - return "i"; - else if (annotation_type.equals(ALint.class)) - return "i"; - else if (annotation_type.equals(ALshort.class)) - return "s"; - else if (annotation_type.equals(ALbyte.class)) - return "b"; - else if (annotation_type.equals(ALfloat.class)) - return "f"; - else if (annotation_type.equals(ALdouble.class)) - return "d"; - else if (annotation_type.equals(ALboolean.class) || annotation_type.equals(ALvoid.class)) - return ""; - else - throw new RuntimeException(annotation_type + " is not allowed"); - } - - public Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind) { - Class type; - switch (kind) { - case INT: - type = ALint.class; - break; - case FLOAT: - type = ALfloat.class; - break; - case DOUBLE: - type = ALdouble.class; - break; - case SHORT: - type = ALshort.class; - break; - case BYTE: - type = ALbyte.class; - break; - case BOOLEAN: - type = ALboolean.class; - break; - default: - throw new RuntimeException(kind + " is not allowed"); - } - return type; - } - - private static Class[] getValidBufferTypes(Class type) { - if (type.equals(IntBuffer.class)) - return new Class[]{ALenum.class, ALint.class, ALsizei.class, ALuint.class}; - else if (type.equals(FloatBuffer.class)) - return new Class[]{ALfloat.class}; - else if (type.equals(ByteBuffer.class)) - return new Class[]{ALboolean.class, ALbyte.class, ALvoid.class}; - else if (type.equals(ShortBuffer.class)) - return new Class[]{ALshort.class}; - else if (type.equals(DoubleBuffer.class)) - return new Class[]{ALdouble.class}; - else - return new Class[]{}; - } - - private static Class[] getValidPrimitiveTypes(Class type) { - if (type.equals(int.class)) - return new Class[]{ALenum.class, ALint.class, ALsizei.class, ALuint.class}; - else if (type.equals(double.class)) - return new Class[]{ALdouble.class}; - else if (type.equals(float.class)) - return new Class[]{ALfloat.class}; - else if (type.equals(short.class)) - return new Class[]{ALshort.class}; - else if (type.equals(byte.class)) - return new Class[]{ALbyte.class}; - else if (type.equals(boolean.class)) - return new Class[]{ALboolean.class}; - else if (type.equals(void.class)) - return new Class[]{ALvoid.class}; - else - return new Class[]{}; - } - - public String getErrorCheckMethodName() { - return "Util.checkALError()"; - } - - public String getRegisterNativesFunctionName() { - return "extal_InitializeClass"; - } - - public String getTypedefPrefix() { - return "ALAPIENTRY"; - } - - public void printNativeIncludes(PrintWriter writer) { - writer.println("#include \"extal.h\""); - } - - public Class getStringElementType() { - return ALubyte.class; - } - - public Class[] getValidAnnotationTypes(Class type) { - Class[] valid_types; - if (Buffer.class.isAssignableFrom(type)) - valid_types = getValidBufferTypes(type); - else if (type.isPrimitive()) - valid_types = getValidPrimitiveTypes(type); - else if (type.equals(String.class)) - valid_types = new Class[]{ALubyte.class}; - else - valid_types = new Class[]{}; - return valid_types; - } - - public Class getVoidType() { - return ALvoid.class; - } - - public Class getInverseType(Class type) { - if (ALuint.class.equals(type)) - return ALint.class; - else if (ALint.class.equals(type)) - return ALuint.class; - else - return null; - } - - public String getAutoTypeFromAnnotation(AnnotationMirror annotation) { - return null; - } -} +/* + * 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 + * 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.generator.openal; + +/** + * + * The OpenAL specific generator behaviour + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALTypeMap.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.Signedness; +import org.lwjgl.util.generator.TypeMap; + +import com.sun.mirror.declaration.*; +import com.sun.mirror.type.*; + +import java.io.*; +import java.lang.annotation.Annotation; +import java.util.*; +import java.nio.*; + +public class ALTypeMap implements TypeMap { + private static final Map native_types_to_primitive; + + static { + native_types_to_primitive = new HashMap(); + native_types_to_primitive.put(ALboolean.class, PrimitiveType.Kind.BOOLEAN); + native_types_to_primitive.put(ALbyte.class, PrimitiveType.Kind.BYTE); + native_types_to_primitive.put(ALenum.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(ALfloat.class, PrimitiveType.Kind.FLOAT); + native_types_to_primitive.put(ALdouble.class, PrimitiveType.Kind.DOUBLE); + native_types_to_primitive.put(ALint.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(ALshort.class, PrimitiveType.Kind.SHORT); + native_types_to_primitive.put(ALsizei.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(ALubyte.class, PrimitiveType.Kind.BYTE); + native_types_to_primitive.put(ALuint.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(ALvoid.class, PrimitiveType.Kind.BYTE); + } + + public PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type) { + PrimitiveType.Kind kind = native_types_to_primitive.get(native_type); + if (kind == null) + throw new RuntimeException("Unsupported type " + native_type); + return kind; + } + + public Signedness getSignednessFromType(Class type) { + if (ALuint.class.equals(type)) + return Signedness.UNSIGNED; + else if (ALint.class.equals(type)) + return Signedness.SIGNED; + else if (ALshort.class.equals(type)) + return Signedness.SIGNED; + else if (ALbyte.class.equals(type)) + return Signedness.SIGNED; + else + return Signedness.NONE; + } + + public String translateAnnotation(Class annotation_type) { + if (annotation_type.equals(ALuint.class)) + return "i"; + else if (annotation_type.equals(ALint.class)) + return "i"; + else if (annotation_type.equals(ALshort.class)) + return "s"; + else if (annotation_type.equals(ALbyte.class)) + return "b"; + else if (annotation_type.equals(ALfloat.class)) + return "f"; + else if (annotation_type.equals(ALdouble.class)) + return "d"; + else if (annotation_type.equals(ALboolean.class) || annotation_type.equals(ALvoid.class)) + return ""; + else + throw new RuntimeException(annotation_type + " is not allowed"); + } + + public Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind) { + Class type; + switch (kind) { + case INT: + type = ALint.class; + break; + case FLOAT: + type = ALfloat.class; + break; + case DOUBLE: + type = ALdouble.class; + break; + case SHORT: + type = ALshort.class; + break; + case BYTE: + type = ALbyte.class; + break; + case BOOLEAN: + type = ALboolean.class; + break; + default: + throw new RuntimeException(kind + " is not allowed"); + } + return type; + } + + private static Class[] getValidBufferTypes(Class type) { + if (type.equals(IntBuffer.class)) + return new Class[]{ALenum.class, ALint.class, ALsizei.class, ALuint.class}; + else if (type.equals(FloatBuffer.class)) + return new Class[]{ALfloat.class}; + else if (type.equals(ByteBuffer.class)) + return new Class[]{ALboolean.class, ALbyte.class, ALvoid.class}; + else if (type.equals(ShortBuffer.class)) + return new Class[]{ALshort.class}; + else if (type.equals(DoubleBuffer.class)) + return new Class[]{ALdouble.class}; + else + return new Class[]{}; + } + + private static Class[] getValidPrimitiveTypes(Class type) { + if (type.equals(int.class)) + return new Class[]{ALenum.class, ALint.class, ALsizei.class, ALuint.class}; + else if (type.equals(double.class)) + return new Class[]{ALdouble.class}; + else if (type.equals(float.class)) + return new Class[]{ALfloat.class}; + else if (type.equals(short.class)) + return new Class[]{ALshort.class}; + else if (type.equals(byte.class)) + return new Class[]{ALbyte.class}; + else if (type.equals(boolean.class)) + return new Class[]{ALboolean.class}; + else if (type.equals(void.class)) + return new Class[]{ALvoid.class}; + else + return new Class[]{}; + } + + public void printCapabilitiesInit(final PrintWriter writer) { + throw new UnsupportedOperationException(); + } + + public String getCapabilities() { + throw new UnsupportedOperationException(); + } + + public void printErrorCheckMethod(final PrintWriter writer, final MethodDeclaration method, final String tabs) { + writer.println(tabs + "Util.checkALError();"); + } + + public String getRegisterNativesFunctionName() { + return "extal_InitializeClass"; + } + + public String getTypedefPostfix() { + return ""; + } + + public String getFunctionPrefix() { + return "ALAPIENTRY"; + } + + public void printNativeIncludes(PrintWriter writer) { + writer.println("#include \"extal.h\""); + } + + public Class getStringElementType() { + return ALubyte.class; + } + + public Class getStringArrayType() { + return ALubyte.class; + } + + public Class getByteBufferArrayType() { + return ALubyte.class; + } + + public Class[] getValidAnnotationTypes(Class type) { + Class[] valid_types; + if (Buffer.class.isAssignableFrom(type)) + valid_types = getValidBufferTypes(type); + else if (type.isPrimitive()) + valid_types = getValidPrimitiveTypes(type); + else if (type.equals(String.class)) + valid_types = new Class[]{ALubyte.class}; + else + valid_types = new Class[]{}; + return valid_types; + } + + public Class getVoidType() { + return ALvoid.class; + } + + public Class getInverseType(Class type) { + if (ALuint.class.equals(type)) + return ALint.class; + else if (ALint.class.equals(type)) + return ALuint.class; + else + return null; + } + + public String getAutoTypeFromAnnotation(AnnotationMirror annotation) { + return null; + } +} diff --git a/src/java/org/lwjgl/util/generator/ALboolean.java b/src/java/org/lwjgl/util/generator/openal/ALboolean.java similarity index 89% rename from src/java/org/lwjgl/util/generator/ALboolean.java rename to src/java/org/lwjgl/util/generator/openal/ALboolean.java index 9c96fe62..ed45b774 100644 --- a/src/java/org/lwjgl/util/generator/ALboolean.java +++ b/src/java/org/lwjgl/util/generator/openal/ALboolean.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface ALboolean { -} +/* + * 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 + * 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.generator.openal; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALboolean.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALboolean { +} diff --git a/src/java/org/lwjgl/util/generator/ALbyte.java b/src/java/org/lwjgl/util/generator/openal/ALbyte.java similarity index 89% rename from src/java/org/lwjgl/util/generator/ALbyte.java rename to src/java/org/lwjgl/util/generator/openal/ALbyte.java index e400aa07..412e4b25 100644 --- a/src/java/org/lwjgl/util/generator/ALbyte.java +++ b/src/java/org/lwjgl/util/generator/openal/ALbyte.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface ALbyte { -} +/* + * 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 + * 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.generator.openal; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALbyte.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALbyte { +} diff --git a/src/java/org/lwjgl/util/generator/ALdouble.java b/src/java/org/lwjgl/util/generator/openal/ALdouble.java similarity index 89% rename from src/java/org/lwjgl/util/generator/ALdouble.java rename to src/java/org/lwjgl/util/generator/openal/ALdouble.java index 721126bb..aa6e0813 100644 --- a/src/java/org/lwjgl/util/generator/ALdouble.java +++ b/src/java/org/lwjgl/util/generator/openal/ALdouble.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface ALdouble { -} +/* + * 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 + * 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.generator.openal; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALdouble.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALdouble { +} diff --git a/src/java/org/lwjgl/util/generator/ALenum.java b/src/java/org/lwjgl/util/generator/openal/ALenum.java similarity index 89% rename from src/java/org/lwjgl/util/generator/ALenum.java rename to src/java/org/lwjgl/util/generator/openal/ALenum.java index 7a6ed660..45636915 100644 --- a/src/java/org/lwjgl/util/generator/ALenum.java +++ b/src/java/org/lwjgl/util/generator/openal/ALenum.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface ALenum { -} +/* + * 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 + * 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.generator.openal; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALenum.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALenum { +} diff --git a/src/java/org/lwjgl/util/generator/ALfloat.java b/src/java/org/lwjgl/util/generator/openal/ALfloat.java similarity index 89% rename from src/java/org/lwjgl/util/generator/ALfloat.java rename to src/java/org/lwjgl/util/generator/openal/ALfloat.java index 1ddbd5c4..39e358a3 100644 --- a/src/java/org/lwjgl/util/generator/ALfloat.java +++ b/src/java/org/lwjgl/util/generator/openal/ALfloat.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface ALfloat { -} +/* + * 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 + * 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.generator.openal; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALfloat.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALfloat { +} diff --git a/src/java/org/lwjgl/util/generator/ALint.java b/src/java/org/lwjgl/util/generator/openal/ALint.java similarity index 89% rename from src/java/org/lwjgl/util/generator/ALint.java rename to src/java/org/lwjgl/util/generator/openal/ALint.java index ce16ce67..ae347e76 100644 --- a/src/java/org/lwjgl/util/generator/ALint.java +++ b/src/java/org/lwjgl/util/generator/openal/ALint.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface ALint { -} +/* + * 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 + * 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.generator.openal; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALint.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALint { +} diff --git a/src/java/org/lwjgl/util/generator/ALshort.java b/src/java/org/lwjgl/util/generator/openal/ALshort.java similarity index 89% rename from src/java/org/lwjgl/util/generator/ALshort.java rename to src/java/org/lwjgl/util/generator/openal/ALshort.java index a978014c..603386b3 100644 --- a/src/java/org/lwjgl/util/generator/ALshort.java +++ b/src/java/org/lwjgl/util/generator/openal/ALshort.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface ALshort { -} +/* + * 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 + * 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.generator.openal; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALshort.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALshort { +} diff --git a/src/java/org/lwjgl/util/generator/ALsizei.java b/src/java/org/lwjgl/util/generator/openal/ALsizei.java similarity index 89% rename from src/java/org/lwjgl/util/generator/ALsizei.java rename to src/java/org/lwjgl/util/generator/openal/ALsizei.java index 6185d796..b079c8f9 100644 --- a/src/java/org/lwjgl/util/generator/ALsizei.java +++ b/src/java/org/lwjgl/util/generator/openal/ALsizei.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface ALsizei { -} +/* + * 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 + * 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.generator.openal; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALsizei.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALsizei { +} diff --git a/src/java/org/lwjgl/util/generator/ALubyte.java b/src/java/org/lwjgl/util/generator/openal/ALubyte.java similarity index 89% rename from src/java/org/lwjgl/util/generator/ALubyte.java rename to src/java/org/lwjgl/util/generator/openal/ALubyte.java index e0151e52..caf22ef5 100644 --- a/src/java/org/lwjgl/util/generator/ALubyte.java +++ b/src/java/org/lwjgl/util/generator/openal/ALubyte.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface ALubyte { -} +/* + * 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 + * 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.generator.openal; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALubyte.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALubyte { +} diff --git a/src/java/org/lwjgl/util/generator/ALuint.java b/src/java/org/lwjgl/util/generator/openal/ALuint.java similarity index 89% rename from src/java/org/lwjgl/util/generator/ALuint.java rename to src/java/org/lwjgl/util/generator/openal/ALuint.java index 5f7acb1f..a31c2a39 100644 --- a/src/java/org/lwjgl/util/generator/ALuint.java +++ b/src/java/org/lwjgl/util/generator/openal/ALuint.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface ALuint { -} +/* + * 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 + * 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.generator.openal; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALuint.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALuint { +} diff --git a/src/java/org/lwjgl/util/generator/ALvoid.java b/src/java/org/lwjgl/util/generator/openal/ALvoid.java similarity index 89% rename from src/java/org/lwjgl/util/generator/ALvoid.java rename to src/java/org/lwjgl/util/generator/openal/ALvoid.java index 5744cd91..9b645eb0 100644 --- a/src/java/org/lwjgl/util/generator/ALvoid.java +++ b/src/java/org/lwjgl/util/generator/openal/ALvoid.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface ALvoid { -} +/* + * 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 + * 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.generator.openal; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALvoid.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALvoid { +} diff --git a/src/java/org/lwjgl/util/generator/opencl/CLCapabilitiesGenerator.java b/src/java/org/lwjgl/util/generator/opencl/CLCapabilitiesGenerator.java new file mode 100644 index 00000000..77247aab --- /dev/null +++ b/src/java/org/lwjgl/util/generator/opencl/CLCapabilitiesGenerator.java @@ -0,0 +1,152 @@ +/* + * 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 + * 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.generator.opencl; + +import org.lwjgl.util.generator.*; + +import java.io.PrintWriter; +import java.util.Collection; +import java.util.Iterator; + +import com.sun.mirror.declaration.InterfaceDeclaration; +import com.sun.mirror.declaration.MethodDeclaration; +import com.sun.mirror.declaration.TypeDeclaration; + +/** + * CLCapabilities generator. + * + * @author Spasi + */ +public class CLCapabilitiesGenerator { + + private static final String SUPPORTED_EXTS = "supported_extensions"; + + static void generateClassPrologue(final PrintWriter writer) { + writer.println("public final class " + CLGeneratorProcessorFactory.CLCAPS_CLASS_NAME + " {"); + writer.println(); + } + + static void generateSymbolAddresses(final PrintWriter writer, final InterfaceDeclaration d) { + final Alias alias_annotation = d.getAnnotation(Alias.class); + final boolean aliased = alias_annotation != null && alias_annotation.postfix().length() > 0; + + boolean first = true; + for ( final MethodDeclaration method : d.getMethods() ) { + if ( method.getAnnotation(Alternate.class) != null || method.getAnnotation(Reuse.class) != null ) + continue; + + if ( first ) { + writer.println("\t// " + d.getSimpleName()); + first = false; + } + writer.print("\tstatic final long " + Utils.getFunctionAddressName(d, method) + " = CL.getFunctionAddress("); + + if ( aliased ) + writer.println("new String [] {\"" + Utils.getFunctionAddressName(d, method) + "\",\"" + method.getSimpleName() + alias_annotation.postfix() + "\"});"); + else + writer.println("\"" + Utils.getFunctionAddressName(d, method) + "\");"); + } + } + + static void generateConstructor(final PrintWriter writer, final Collection interface_decls) { + writer.println("\tprivate static final Set " + SUPPORTED_EXTS + " = new HashSet();"); + writer.println(); + writer.println("\tprivate " + CLGeneratorProcessorFactory.CLCAPS_CLASS_NAME + "() {}"); + writer.println(); + writer.println("\tstatic {"); + + for ( final TypeDeclaration d : interface_decls ) { + if ( d.getMethods().isEmpty() ) + continue; + + writer.println("\t\tif ( " + getExtensionSupportedName(d.getSimpleName()) + "() )"); + writer.println("\t\t\t" + SUPPORTED_EXTS + ".add(\"" + CLGeneratorProcessorFactory.getExtensionName(d.getSimpleName()) + "\");"); + } + + writer.println("\t}\n"); + } + + static void generateExtensionSupported(final PrintWriter writer) { + writer.println("\tstatic boolean isExtensionSupported(final String name) {\n" + + "\t\treturn " + SUPPORTED_EXTS + ".contains(name);\n" + + "\t}\n"); + } + + static void generateExtensionChecks(final PrintWriter writer, final InterfaceDeclaration d) { + Iterator methods = d.getMethods().iterator(); + if ( !methods.hasNext() ) + return; + + writer.println("\tstatic boolean " + getExtensionSupportedName(d.getSimpleName()) + "() {"); + writer.println("\t\treturn "); + + boolean first = true; + while ( methods.hasNext() ) { + MethodDeclaration method = methods.next(); + if ( method.getAnnotation(Alternate.class) != null ) + continue; + + if ( !first ) + writer.println(" &"); + else + first = false; + + final boolean optional = method.getAnnotation(Optional.class) != null; + + writer.print("\t\t\t"); + if ( optional ) + writer.print('('); + writer.print(Utils.getFunctionAddressName(d, method) + " != 0"); + if ( optional ) + writer.print(" || true)"); + } + writer.println(";"); + writer.println("\t}"); + writer.println(); + } + + private static String getExtensionSupportedName(final String class_name) { + return "is" + class_name + "Supported"; + } + + public static void generateCapabilitiesGetters(final PrintWriter writer) { + writer.println("\tpublic static CLPlatformCapabilities getPlatformCapabilities(final CLPlatform platform) {\n" + + "\t\treturn CLPlatformImpl.getCapabilities(platform);\n" + + "\t}\n"); + + writer.println("\tpublic static CLDeviceCapabilities getDeviceCapabilities(final CLDevice device) {\n" + + "\t\treturn CLDeviceImpl.getCapabilities(device);\n" + + "\t}\n"); + + } +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/opencl/CLDeviceExtension.java b/src/java/org/lwjgl/util/generator/opencl/CLDeviceExtension.java new file mode 100644 index 00000000..f34e8f57 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/opencl/CLDeviceExtension.java @@ -0,0 +1,41 @@ +/* + * 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.util.generator.opencl; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +/** Extension templates marked with @CLDeviceExtension will be considered CL device extensions. */ +@Target(ElementType.TYPE) +public @interface CLDeviceExtension { + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/opencl/CLGeneratorProcessorFactory.java b/src/java/org/lwjgl/util/generator/opencl/CLGeneratorProcessorFactory.java new file mode 100644 index 00000000..b5bba949 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/opencl/CLGeneratorProcessorFactory.java @@ -0,0 +1,183 @@ +/* + * 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 + * 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.generator.opencl; + +import org.lwjgl.PointerWrapper; +import org.lwjgl.opencl.CLDevice; +import org.lwjgl.opencl.CLPlatform; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.lang.annotation.Annotation; +import java.util.Arrays; +import java.util.Collection; +import java.util.Set; + +import com.sun.mirror.apt.*; +import com.sun.mirror.declaration.AnnotationTypeDeclaration; +import com.sun.mirror.declaration.InterfaceDeclaration; +import com.sun.mirror.declaration.TypeDeclaration; +import com.sun.mirror.util.DeclarationFilter; + +import static java.util.Collections.*; + +/** + * Generator tool for creating the OpenCL capabilities classes + * + * @author Spasi + */ +public class CLGeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener { + + public static final String CLCAPS_CLASS_NAME = "CLCapabilities"; + public static final String PLATFORM_CAPS_CLASS_NAME = "CLPlatformCapabilities"; + public static final String DEVICE_CAPS_CLASS_NAME = "CLDeviceCapabilities"; + + private static final String EXTENSION_PREFIX = "CL_"; + private static final String CORE_PREFIX = "Open"; + + private static boolean first_round = true; + + // Process any set of annotations + private static final Collection supportedAnnotations = unmodifiableCollection(Arrays.asList("*")); + + public Collection supportedAnnotationTypes() { + return supportedAnnotations; + } + + public Collection supportedOptions() { + return unmodifiableCollection(Arrays.asList("-Acontextspecific")); + } + + public void roundComplete(RoundCompleteEvent event) { + first_round = false; + } + + public AnnotationProcessor getProcessorFor(Set atds, AnnotationProcessorEnvironment env) { + // Only process the initial types, not the generated ones + if ( first_round ) { + env.addListener(this); + return new GeneratorProcessor(env); + } else + return AnnotationProcessors.NO_OP; + } + + static String getExtensionName(String interface_name) { + if ( interface_name.startsWith("CL") ) + return CORE_PREFIX + interface_name; + else + return EXTENSION_PREFIX + interface_name; + } + + private static class GeneratorProcessor implements AnnotationProcessor { + + private final AnnotationProcessorEnvironment env; + + GeneratorProcessor(AnnotationProcessorEnvironment env) { + this.env = env; + } + + public void process() { + try { + generateCLCapabilitiesSource(); + generateCLPDCapabilitiesSource(CLPlatformExtension.class, PLATFORM_CAPS_CLASS_NAME, CLPlatform.class, "platform"); + generateCLPDCapabilitiesSource(CLDeviceExtension.class, DEVICE_CAPS_CLASS_NAME, CLDevice.class, "device"); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + private static void printHeader(final PrintWriter writer) { + writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */"); + writer.println(); + writer.println("package org.lwjgl.opencl;"); + writer.println(); + writer.println("import java.util.*;"); + writer.println(); + } + + private void generateCLCapabilitiesSource() throws IOException { + final PrintWriter writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "org.lwjgl.opencl", new File(CLCAPS_CLASS_NAME + ".java"), null); + printHeader(writer); + + CLCapabilitiesGenerator.generateClassPrologue(writer); + + final Collection templates = DeclarationFilter.getFilter(InterfaceDeclaration.class).filter(env.getSpecifiedTypeDeclarations()); + + for ( final TypeDeclaration t : templates ) { + if ( t.getAnnotation(CLPlatformExtension.class) == null && t.getAnnotation(CLDeviceExtension.class) == null && !t.getSimpleName().startsWith("CL") ) + throw new RuntimeException("An OpenCL extension is missing an extension type annotation: " + t.getSimpleName()); + + CLCapabilitiesGenerator.generateSymbolAddresses(writer, (InterfaceDeclaration)t); + } + writer.println(); + + CLCapabilitiesGenerator.generateConstructor(writer, templates); + + CLCapabilitiesGenerator.generateCapabilitiesGetters(writer); + + CLCapabilitiesGenerator.generateExtensionSupported(writer); + + for ( final TypeDeclaration template : templates ) + CLCapabilitiesGenerator.generateExtensionChecks(writer, (InterfaceDeclaration)template); + + writer.println("}"); + writer.close(); + } + + private void generateCLPDCapabilitiesSource(final Class capsType, final String capsName, final Class objectType, final String objectName) throws IOException { + final PrintWriter writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "org.lwjgl.opencl", new File(capsName + ".java"), null); + printHeader(writer); + + CLPDCapabilitiesGenerator.generateClassPrologue(writer, capsName); + + final Collection templates = DeclarationFilter.getFilter(InterfaceDeclaration.class).filter(env.getSpecifiedTypeDeclarations()); + + for ( final TypeDeclaration t : templates ) { + if ( t.getAnnotation(capsType) != null ) + CLPDCapabilitiesGenerator.generateExtensions(writer, (InterfaceDeclaration)t); + } + writer.println(); + + CLPDCapabilitiesGenerator.generateConstructor(writer, templates, capsType, capsName, objectType, objectName); + + CLPDCapabilitiesGenerator.generateGetters(writer); + + CLPDCapabilitiesGenerator.generateToString(writer, templates, capsType, capsName, objectType, objectName); + + writer.println("}"); + writer.close(); + } + + } +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/opencl/CLPDCapabilitiesGenerator.java b/src/java/org/lwjgl/util/generator/opencl/CLPDCapabilitiesGenerator.java new file mode 100644 index 00000000..c697755b --- /dev/null +++ b/src/java/org/lwjgl/util/generator/opencl/CLPDCapabilitiesGenerator.java @@ -0,0 +1,147 @@ +/* + * 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 + * 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.generator.opencl; + +import org.lwjgl.PointerWrapper; +import org.lwjgl.util.generator.Private; + +import java.io.PrintWriter; +import java.lang.annotation.Annotation; +import java.util.Collection; + +import com.sun.mirror.declaration.InterfaceDeclaration; +import com.sun.mirror.declaration.TypeDeclaration; + +/** + * CL platform/device capabilities generator. + * + * @author Spasi + */ +public class CLPDCapabilitiesGenerator { + + // TODO: Add future versions here + private static final int[][] CL_VERSIONS = { + { 1 }, // OpenCL 1 + }; + + static void generateClassPrologue(final PrintWriter writer, final String name) { + writer.println("public class " + name + " {"); + writer.println(); + writer.println("\tpublic final int majorVersion;"); + writer.println("\tpublic final int minorVersion;"); + writer.println(); + for ( int major = 1; major <= CL_VERSIONS.length; major++ ) { + for ( final int minor : CL_VERSIONS[major - 1] ) + writer.println("\tpublic final boolean OpenCL" + Integer.toString(major) + Integer.toString(minor) + ";"); + } + writer.println(); + } + + static void generateExtensions(final PrintWriter writer, final InterfaceDeclaration d) { + writer.print("\t"); + + if ( d.getAnnotation(Private.class) == null ) + writer.print("public "); + + writer.println("final boolean " + CLGeneratorProcessorFactory.getExtensionName(d.getSimpleName()) + ";"); + } + + static void generateConstructor(final PrintWriter writer, final Collection templates, + final Class capsType, final String capsName, + final Class objectType, final String objectName) { + writer.println("\tpublic " + capsName + "(final " + objectType.getSimpleName() + ' ' + objectName + ") {"); + + final String methodName = Character.toUpperCase(objectName.charAt(0)) + objectName.substring(1); + writer.println("\t\tfinal String extensionList = " + objectName + ".getInfoString(CL10.CL_" + objectName.toUpperCase() + "_EXTENSIONS);\n" + + "\t\tfinal String version = " + objectName + ".getInfoString(CL10.CL_" + objectName.toUpperCase() + "_VERSION);\n" + + "\t\tif ( !version.startsWith(\"OpenCL \") )\n" + + "\t\t\tthrow new RuntimeException(\"Invalid OpenCL version string: \" + version);\n\n" + + "\t\ttry {\n" + + "\t\t\tfinal StringTokenizer tokenizer = new StringTokenizer(version.substring(7), \". \");\n" + + "\n" + + "\t\t\tmajorVersion = Integer.parseInt(tokenizer.nextToken());\n" + + "\t\t\tminorVersion = Integer.parseInt(tokenizer.nextToken());\n"); + + for ( int major = 1; major <= CL_VERSIONS.length; major++ ) { + for ( final int minor : CL_VERSIONS[major - 1] ) + writer.println("\t\t\tOpenCL" + Integer.toString(major) + Integer.toString(minor) + " = " + major + " < majorVersion || (" + major + " == majorVersion && " + minor + " <= minorVersion);"); + } + + writer.println("\t\t} catch (RuntimeException e) {\n" + + "\t\t\tthrow new RuntimeException(\"The major and/or minor OpenCL version \\\"\" + version + \"\\\" is malformed: \" + e.getMessage());\n" + + "\t\t}\n"); + + writer.println("\t\tfinal Set extensions = APIUtil.getExtensions(extensionList);"); + + for ( final TypeDeclaration t : templates ) { + if ( t.getAnnotation(capsType) == null ) + continue; + + writer.print("\t\t" + CLGeneratorProcessorFactory.getExtensionName(t.getSimpleName()) + " = extensions.contains(\"" + CLGeneratorProcessorFactory.getExtensionName(t.getSimpleName()).toLowerCase() + "\")"); + if ( !t.getMethods().isEmpty() ) + writer.print(" && CLCapabilities.is" + t.getSimpleName() + "Supported()"); + writer.println(";"); + } + + writer.println("\t}\n"); + } + + public static void generateGetters(final PrintWriter writer) { + writer.println("\tpublic int getMajorVersion() {"); + writer.println("\t\treturn majorVersion;"); + writer.println("\t}\n"); + + writer.println("\tpublic int getMinorVersion() {"); + writer.println("\t\treturn minorVersion;"); + writer.println("\t}\n"); + } + + public static void generateToString(final PrintWriter writer, final Collection templates, final Class capsType, final String capsName, final Class objectType, final String objectName) { + writer.println("\tpublic String toString() {"); + writer.println("\t\tfinal StringBuilder buf = new StringBuilder();\n"); + + writer.println("\t\tbuf.append(\"OpenCL \").append(majorVersion).append('.').append(minorVersion);"); + writer.println(); + writer.println("\t\tbuf.append(\" - Extensions: \");"); + for ( final TypeDeclaration t : templates ) { + if ( t.getAnnotation(capsType) == null ) + continue; + + writer.println("\t\tif ( " + CLGeneratorProcessorFactory.getExtensionName(t.getSimpleName()) + " ) buf.append(\"" + CLGeneratorProcessorFactory.getExtensionName(t.getSimpleName()).toLowerCase() + " \");"); + } + + writer.println("\n\t\treturn buf.toString();"); + writer.println("\t}\n"); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/opencl/CLPlatformExtension.java b/src/java/org/lwjgl/util/generator/opencl/CLPlatformExtension.java new file mode 100644 index 00000000..e8ddadc1 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/opencl/CLPlatformExtension.java @@ -0,0 +1,41 @@ +/* + * 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.util.generator.opencl; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +/** Extension templates marked with @CLPlatformExtension will be considered CL platform extensions. */ +@Target(ElementType.TYPE) +public @interface CLPlatformExtension { + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/opencl/CLTypeMap.java b/src/java/org/lwjgl/util/generator/opencl/CLTypeMap.java new file mode 100644 index 00000000..6a2c13bb --- /dev/null +++ b/src/java/org/lwjgl/util/generator/opencl/CLTypeMap.java @@ -0,0 +1,266 @@ +/* + * 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.util.generator.opencl; + +/** + * + * OpenCL specific generator behaviour + * + * @author Spasi + */ + +import org.lwjgl.PointerBuffer; +import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLreturn; + +import java.io.PrintWriter; +import java.lang.annotation.Annotation; +import java.nio.*; +import java.util.HashMap; +import java.util.Map; + +import com.sun.mirror.declaration.AnnotationMirror; +import com.sun.mirror.declaration.MethodDeclaration; +import com.sun.mirror.declaration.ParameterDeclaration; +import com.sun.mirror.type.PrimitiveType; + +public class CLTypeMap implements TypeMap { + + private static final Map native_types_to_primitive; + + static { + native_types_to_primitive = new HashMap(); + native_types_to_primitive.put(cl_void.class, PrimitiveType.Kind.BYTE); + native_types_to_primitive.put(cl_byte.class, PrimitiveType.Kind.BYTE); + native_types_to_primitive.put(cl_char.class, PrimitiveType.Kind.BYTE); + native_types_to_primitive.put(cl_uchar.class, PrimitiveType.Kind.BYTE); + native_types_to_primitive.put(cl_short.class, PrimitiveType.Kind.SHORT); + native_types_to_primitive.put(cl_bool.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(cl_int.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(cl_uint.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(cl_long.class, PrimitiveType.Kind.LONG); + native_types_to_primitive.put(size_t.class, PrimitiveType.Kind.LONG); + native_types_to_primitive.put(cl_bitfield.class, PrimitiveType.Kind.LONG); + native_types_to_primitive.put(cl_float.class, PrimitiveType.Kind.FLOAT); + native_types_to_primitive.put(cl_double.class, PrimitiveType.Kind.DOUBLE); + } + + public PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type) { + PrimitiveType.Kind kind = native_types_to_primitive.get(native_type); + if ( kind == null ) + throw new RuntimeException("Unsupported type " + native_type); + return kind; + } + + public void printCapabilitiesInit(final PrintWriter writer) { + } + + public String getCapabilities() { + return "CLCapabilities"; + } + + 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 + writer.println(tabs + "Util.checkCLError(" + check.value() + ".get(" + check.value() + ".position()));"); + else { + final Class return_type = Utils.getJavaType(method.getReturnType()); + if ( return_type == int.class ) + writer.println(tabs + "Util.checkCLError(__result);"); + else { + boolean hasErrCodeParam = false; + for ( final ParameterDeclaration param : method.getParameters() ) { + if ( "errcode_ret".equals(param.getSimpleName()) && Utils.getJavaType(param.getType()) == IntBuffer.class ) { + hasErrCodeParam = true; + break; + } + } + if ( hasErrCodeParam ) + throw new RuntimeException("A method is missing the @Check annotation: " + method.toString()); + } + } + } + + public String getRegisterNativesFunctionName() { + return "extcl_InitializeClass"; + } + + public Signedness getSignednessFromType(Class type) { + if ( cl_uint.class.equals(type) ) + return Signedness.UNSIGNED; + else if ( cl_int.class.equals(type) ) + return Signedness.SIGNED; + else + return Signedness.NONE; + } + + public String translateAnnotation(Class annotation_type) { + if ( annotation_type.equals(cl_uint.class) || annotation_type.equals(cl_int.class) ) + return "i"; + else if ( annotation_type.equals(cl_short.class) ) + return "s"; + else if ( annotation_type.equals(cl_byte.class) ) + return "b"; + else if ( annotation_type.equals(cl_float.class) ) + return "f"; + else if ( annotation_type.equals(cl_double.class) ) + return "d"; + else + throw new RuntimeException(annotation_type + " is not allowed"); + } + + public Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind) { + Class type; + switch ( kind ) { + case INT: + type = cl_int.class; + break; + case DOUBLE: + type = cl_double.class; + break; + case FLOAT: + type = cl_float.class; + break; + case SHORT: + type = cl_short.class; + break; + case BYTE: + type = cl_byte.class; + break; + case LONG: + type = cl_long.class; + break; + case BOOLEAN: + type = cl_bool.class; + break; + default: + throw new RuntimeException(kind + " is not allowed"); + } + return type; + } + + public Class getVoidType() { + return cl_void.class; + } + + public Class getStringElementType() { + return cl_char.class; + } + + public Class getStringArrayType() { + return cl_char.class; + } + + public Class getByteBufferArrayType() { + return cl_uchar.class; + } + + private static Class[] getValidBufferTypes(Class type) { + if ( type.equals(IntBuffer.class) ) + return new Class[] { cl_int.class, cl_uint.class }; + else if ( type.equals(FloatBuffer.class) ) + return new Class[] { cl_float.class }; + else if ( type.equals(ByteBuffer.class) ) + return new Class[] { cl_byte.class, cl_char.class, cl_uchar.class, cl_void.class }; + else if ( type.equals(ShortBuffer.class) ) + return new Class[] { cl_short.class }; + else if ( type.equals(DoubleBuffer.class) ) + return new Class[] { cl_double.class }; + else if ( type.equals(LongBuffer.class) ) + return new Class[] { cl_long.class }; + else if ( type.equals(PointerBuffer.class) ) + return new Class[] { size_t.class }; + else + return new Class[] { }; + } + + private static Class[] getValidPrimitiveTypes(Class type) { + if ( type.equals(long.class) ) + return new Class[] { cl_long.class, size_t.class, cl_bitfield.class }; + else if ( type.equals(int.class) ) + return new Class[] { cl_int.class, cl_uint.class, cl_bool.class }; + else if ( type.equals(double.class) ) + return new Class[] { cl_double.class }; + else if ( type.equals(float.class) ) + return new Class[] { cl_float.class }; + else if ( type.equals(short.class) ) + return new Class[] { cl_short.class }; + else if ( type.equals(byte.class) ) + return new Class[] { cl_byte.class, cl_char.class, cl_uchar.class }; + else if ( type.equals(boolean.class) ) + return new Class[] { cl_bool.class }; + else if ( type.equals(void.class) ) + return new Class[] { cl_void.class }; + else + return new Class[] { }; + } + + public String getTypedefPostfix() { + return "CL_API_ENTRY "; + } + + public String getFunctionPrefix() { + return "CL_API_CALL"; + } + + public void printNativeIncludes(PrintWriter writer) { + writer.println("#include \"extcl.h\""); + } + + public Class[] getValidAnnotationTypes(Class type) { + Class[] valid_types; + if ( Buffer.class.isAssignableFrom(type) || PointerBuffer.class.isAssignableFrom(type) ) + valid_types = getValidBufferTypes(type); + else if ( type.isPrimitive() ) + valid_types = getValidPrimitiveTypes(type); + else if ( String.class.equals(type) ) + valid_types = new Class[] { cl_byte.class }; + else if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(type) ) + valid_types = new Class[] { PointerWrapper.class }; + else if ( ByteBuffer[].class == type ) + valid_types = new Class[] { cl_char.class, cl_uchar.class }; + else if ( void.class.equals(type) ) + valid_types = new Class[] { GLreturn.class }; + else + valid_types = new Class[] { }; + return valid_types; + } + + public Class getInverseType(Class type) { + return null; + } + + public String getAutoTypeFromAnnotation(AnnotationMirror annotation) { + return null; + } +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/opencl/cl_bitfield.java b/src/java/org/lwjgl/util/generator/opencl/cl_bitfield.java new file mode 100644 index 00000000..4b216512 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/opencl/cl_bitfield.java @@ -0,0 +1,43 @@ +/* + * 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.util.generator.opencl; + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@NativeType +@Target({ ElementType.PARAMETER }) +public @interface cl_bitfield { + String alias() default ""; +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/opencl/cl_bool.java b/src/java/org/lwjgl/util/generator/opencl/cl_bool.java new file mode 100644 index 00000000..73792b67 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/opencl/cl_bool.java @@ -0,0 +1,43 @@ +/* + * 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.util.generator.opencl; + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@NativeType +@Target({ ElementType.PARAMETER }) +public @interface cl_bool { + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/opencl/cl_byte.java b/src/java/org/lwjgl/util/generator/opencl/cl_byte.java new file mode 100644 index 00000000..28bc59e3 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/opencl/cl_byte.java @@ -0,0 +1,43 @@ +/* + * 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.util.generator.opencl; + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@NativeType +@Target({ ElementType.PARAMETER, ElementType.METHOD }) +public @interface cl_byte { + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/opencl/cl_char.java b/src/java/org/lwjgl/util/generator/opencl/cl_char.java new file mode 100644 index 00000000..c275db41 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/opencl/cl_char.java @@ -0,0 +1,43 @@ +/* + * 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.util.generator.opencl; + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@NativeType +@Target({ ElementType.PARAMETER }) +public @interface cl_char { + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/opencl/cl_double.java b/src/java/org/lwjgl/util/generator/opencl/cl_double.java new file mode 100644 index 00000000..8459a87e --- /dev/null +++ b/src/java/org/lwjgl/util/generator/opencl/cl_double.java @@ -0,0 +1,43 @@ +/* + * 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.util.generator.opencl; + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@NativeType +@Target({ ElementType.PARAMETER, ElementType.METHOD }) +public @interface cl_double { + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/opencl/cl_float.java b/src/java/org/lwjgl/util/generator/opencl/cl_float.java new file mode 100644 index 00000000..44c9cb18 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/opencl/cl_float.java @@ -0,0 +1,43 @@ +/* + * 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.util.generator.opencl; + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@NativeType +@Target({ ElementType.PARAMETER, ElementType.METHOD }) +public @interface cl_float { + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/opencl/cl_int.java b/src/java/org/lwjgl/util/generator/opencl/cl_int.java new file mode 100644 index 00000000..b515e4e3 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/opencl/cl_int.java @@ -0,0 +1,42 @@ +/* + * 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.util.generator.opencl; + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@NativeType +@Target({ ElementType.PARAMETER, ElementType.METHOD }) +public @interface cl_int { +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/opencl/cl_long.java b/src/java/org/lwjgl/util/generator/opencl/cl_long.java new file mode 100644 index 00000000..c34aa6a6 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/opencl/cl_long.java @@ -0,0 +1,43 @@ +/* + * 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.util.generator.opencl; + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@NativeType +@Target({ ElementType.PARAMETER }) +public @interface cl_long { + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/opencl/cl_short.java b/src/java/org/lwjgl/util/generator/opencl/cl_short.java new file mode 100644 index 00000000..23ce10d6 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/opencl/cl_short.java @@ -0,0 +1,43 @@ +/* + * 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.util.generator.opencl; + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@NativeType +@Target({ ElementType.PARAMETER, ElementType.METHOD }) +public @interface cl_short { + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/opencl/cl_uchar.java b/src/java/org/lwjgl/util/generator/opencl/cl_uchar.java new file mode 100644 index 00000000..825a479e --- /dev/null +++ b/src/java/org/lwjgl/util/generator/opencl/cl_uchar.java @@ -0,0 +1,43 @@ +/* + * 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.util.generator.opencl; + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@NativeType +@Target({ ElementType.PARAMETER }) +public @interface cl_uchar { + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/opencl/cl_uint.java b/src/java/org/lwjgl/util/generator/opencl/cl_uint.java new file mode 100644 index 00000000..50a335a3 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/opencl/cl_uint.java @@ -0,0 +1,42 @@ +/* + * 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.util.generator.opencl; + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@NativeType +@Target({ ElementType.PARAMETER, ElementType.METHOD }) +public @interface cl_uint { +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/opencl/cl_void.java b/src/java/org/lwjgl/util/generator/opencl/cl_void.java new file mode 100644 index 00000000..6cf56311 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/opencl/cl_void.java @@ -0,0 +1,45 @@ +/* + * 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.util.generator.opencl; + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +import com.sun.mirror.type.PrimitiveType; + +@NativeType +@Target({ ElementType.PARAMETER, ElementType.METHOD }) +public @interface cl_void { + PrimitiveType.Kind value() default PrimitiveType.Kind.BYTE; +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/opencl/size_t.java b/src/java/org/lwjgl/util/generator/opencl/size_t.java new file mode 100644 index 00000000..b6bdeab7 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/opencl/size_t.java @@ -0,0 +1,43 @@ +/* + * 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.util.generator.opencl; + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@NativeType +@Target({ ElementType.PARAMETER }) +public @interface size_t { + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java b/src/java/org/lwjgl/util/generator/opengl/GLCapabilitiesGenerator.java similarity index 91% rename from src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java rename to src/java/org/lwjgl/util/generator/opengl/GLCapabilitiesGenerator.java index 84146976..a3928327 100644 --- a/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLCapabilitiesGenerator.java @@ -1,319 +1,328 @@ -/* - * 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 - * 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.generator; - -import java.io.PrintWriter; -import java.util.Arrays; -import java.util.Collection; -import java.util.EnumSet; -import java.util.Iterator; - -import com.sun.mirror.declaration.InterfaceDeclaration; -import com.sun.mirror.declaration.MethodDeclaration; -import com.sun.mirror.type.InterfaceType; - -/** - * Generator visitor for the context capabilities generator tool - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ -public class ContextCapabilitiesGenerator { - - private static final String STUBS_LOADED_NAME = "loaded_stubs"; - private static final String ALL_INIT_METHOD_NAME = "initAllStubs"; - private static final String POINTER_INITIALIZER_POSTFIX = "_initNativeFunctionAddresses"; - private static final String CACHED_EXTS_VAR_NAME = "supported_extensions"; - private static final String PROFILE_MASK_VAR_NAME = "profileMask"; - private static final String EXTENSION_PREFIX = "GL_"; - private static final String CORE_PREFIX = "Open"; - - 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 StateTracker tracker = new StateTracker();"); - writer.println(); - if ( !context_specific ) { - writer.println("\tprivate static boolean " + STUBS_LOADED_NAME + " = false;"); - } - } - - public static void generateInitializerPrologue(PrintWriter writer) { - writer.println("\t" + Utils.CONTEXT_CAPS_CLASS_NAME + "(boolean forwardCompatible) throws LWJGLException {"); - writer.println("\t\tSet " + CACHED_EXTS_VAR_NAME + " = " + ALL_INIT_METHOD_NAME + "(forwardCompatible);"); - } - - private static String translateFieldName(String interface_name) { - if ( interface_name.startsWith("GL") ) - return CORE_PREFIX + interface_name; - else - return EXTENSION_PREFIX + interface_name; - } - - public static void generateSuperClassAdds(PrintWriter writer, InterfaceDeclaration d) { - Collection super_interfaces = d.getSuperinterfaces(); - if ( super_interfaces.size() > 1 ) - throw new RuntimeException(d + " extends more than one other interface"); - if ( super_interfaces.size() == 1 ) { - InterfaceType super_interface = super_interfaces.iterator().next(); - writer.print("\t\tif (" + CACHED_EXTS_VAR_NAME + ".contains(\""); - writer.println(translateFieldName(d.getSimpleName()) + "\"))"); - writer.print("\t\t\t"); - generateAddExtension(writer, super_interface.getDeclaration()); - } - } - - public static void generateInitializer(PrintWriter writer, InterfaceDeclaration d) { - String translated_field_name = translateFieldName(d.getSimpleName()); - writer.print("\t\tthis." + translated_field_name + " = "); - writer.print(CACHED_EXTS_VAR_NAME + ".contains(\""); - writer.print(translated_field_name + "\")"); - Collection super_interfaces = d.getSuperinterfaces(); - if ( super_interfaces.size() > 1 ) - throw new RuntimeException(d + " extends more than one other interface"); - if ( super_interfaces.size() == 1 ) { - InterfaceType super_interface = super_interfaces.iterator().next(); - writer.println(); - writer.print("\t\t\t&& " + CACHED_EXTS_VAR_NAME + ".contains(\""); - writer.print(translateFieldName(super_interface.getDeclaration().getSimpleName()) + "\")"); - } - Alias alias_annotation = d.getAnnotation(Alias.class); - if ( alias_annotation != null ) { - writer.println(); - writer.print("\t\t\t|| " + CACHED_EXTS_VAR_NAME + ".contains(\""); - writer.print(translateFieldName(alias_annotation.value()) + "\")"); - } - writer.println(";"); - } - - private static String getAddressesInitializerName(String class_name) { - return class_name + POINTER_INITIALIZER_POSTFIX; - } - - public static void generateInitStubsPrologue(PrintWriter writer, boolean context_specific) { - writer.println("\tprivate Set " + ALL_INIT_METHOD_NAME + "(boolean forwardCompatible) throws LWJGLException {"); - - // Load the basic pointers we need to detect OpenGL version and supported extensions. - writer.println("\t\tGL11_glGetError_pointer = GLContext.getFunctionAddress(\"glGetError\");"); - writer.println("\t\tGL11_glGetString_pointer = GLContext.getFunctionAddress(\"glGetString\");"); - - // Initialize GL11.glGetIntegerv and GL30.glGetStringi here, in case we have created an OpenGL 3.0 context. - // (they will be used in GLContext.getSupportedExtensions) - writer.println("\t\tGL11_glGetIntegerv_pointer = GLContext.getFunctionAddress(\"glGetIntegerv\");"); - writer.println("\t\tGL30_glGetStringi_pointer = GLContext.getFunctionAddress(\"glGetStringi\");"); - - // Get the supported extensions set. - writer.println("\t\tGLContext.setCapabilities(this);"); - writer.println("\t\tSet " + CACHED_EXTS_VAR_NAME + " = new HashSet(256);"); - writer.println("\t\tint " + PROFILE_MASK_VAR_NAME + " = GLContext.getSupportedExtensions(" + CACHED_EXTS_VAR_NAME + ");"); - - // Force forward compatible mode when OpenGL version is 3.1 or higher and ARB_compatibility is not available. - writer.println("\t\tif ( supported_extensions.contains(\"OpenGL31\") && !(supported_extensions.contains(\"GL_ARB_compatibility\") || (profileMask & GL32.GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0) )"); - writer.println("\t\t\tforwardCompatible = true;"); - - if ( !context_specific ) { - writer.println("\t\tif (" + STUBS_LOADED_NAME + ")"); - writer.println("\t\t\treturn GLContext.getSupportedExtensions();"); - writer.println("\t\torg.lwjgl.opengl.GL11." + Utils.STUB_INITIALIZER_NAME + "();"); - } else { - writer.println("\t\tif (!" + getAddressesInitializerName("GL11") + "(forwardCompatible))"); - writer.println("\t\t\tthrow new LWJGLException(\"GL11 not supported\");"); - } - } - - public static void generateInitStubsEpilogue(PrintWriter writer, boolean context_specific) { - if ( !context_specific ) { - writer.println("\t\t" + STUBS_LOADED_NAME + " = true;"); - } - writer.println("\t\treturn " + CACHED_EXTS_VAR_NAME + ";"); - writer.println("\t}"); - } - - public static void generateUnloadStubs(PrintWriter writer, InterfaceDeclaration d) { - if ( d.getMethods().size() > 0 ) { - writer.print("\t\tGLContext.resetNativeStubs(" + Utils.getSimpleClassName(d)); - writer.println(".class);"); - } - } - - public static void generateInitStubs(PrintWriter writer, InterfaceDeclaration d, boolean context_specific) { - if ( d.getMethods().size() > 0 ) { - if ( context_specific ) { - final Alias alias_annotation = d.getAnnotation(Alias.class); - - if ( d.getAnnotation(ForceInit.class) != null ) - writer.println("\t\t" + CACHED_EXTS_VAR_NAME + ".add(\"" + translateFieldName(d.getSimpleName()) + "\");"); - writer.print("\t\tif ("); - if ( alias_annotation != null ) - writer.print("("); - writer.print(CACHED_EXTS_VAR_NAME + ".contains(\""); - writer.print(translateFieldName(d.getSimpleName()) + "\")"); - if ( alias_annotation != null ) { - writer.print(" || " + CACHED_EXTS_VAR_NAME + ".contains(\""); - writer.print(translateFieldName(alias_annotation.value()) + "\"))"); - } - writer.print(" && !" + getAddressesInitializerName(d.getSimpleName()) + "("); - if ( d.getAnnotation(DeprecatedGL.class) != null ) - writer.print("forwardCompatible"); - if ( d.getAnnotation(Dependent.class) != null ) { - if ( d.getAnnotation(DeprecatedGL.class) != null ) - writer.print(","); - writer.print("supported_extensions"); - } - if ( alias_annotation != null ) { - writer.println(")) {"); - writer.print("\t\t\tremove(" + CACHED_EXTS_VAR_NAME + ", \""); - writer.println(translateFieldName(alias_annotation.value()) + "\");"); - } else - writer.println("))"); - writer.print("\t\t\tremove(" + CACHED_EXTS_VAR_NAME + ", \""); - writer.println(translateFieldName(d.getSimpleName()) + "\");"); - if ( alias_annotation != null ) - writer.println("\t\t}"); - } else { - writer.print("\t\tGLContext." + Utils.STUB_INITIALIZER_NAME + "(" + Utils.getSimpleClassName(d)); - writer.println(".class, " + CACHED_EXTS_VAR_NAME + ", \"" + translateFieldName(d.getSimpleName()) + "\");"); - } - } - } - - private static void generateAddExtension(PrintWriter writer, InterfaceDeclaration d) { - writer.print(CACHED_EXTS_VAR_NAME + ".add(\""); - writer.println(translateFieldName(d.getSimpleName()) + "\");"); - } - - public static void generateAddressesInitializers(PrintWriter writer, InterfaceDeclaration d) { - Iterator methods = d.getMethods().iterator(); - if ( !methods.hasNext() ) - return; - - writer.print("\tprivate boolean " + getAddressesInitializerName(d.getSimpleName()) + "("); - - boolean optional; - boolean deprecated = d.getAnnotation(DeprecatedGL.class) != null; - Dependent dependent = d.getAnnotation(Dependent.class); - if ( deprecated ) - writer.print("boolean forwardCompatible"); - if ( dependent != null ) { - if ( deprecated ) - writer.print(","); - writer.print("Set supported_extensions"); - } - - Alias alias_annotation = d.getAnnotation(Alias.class); - boolean aliased = alias_annotation != null && alias_annotation.postfix().length() > 0; - - writer.println(") {"); - writer.println("\t\treturn "); - - boolean first = true; - while ( methods.hasNext() ) { - MethodDeclaration method = methods.next(); - if ( method.getAnnotation(Alternate.class) != null ) - continue; - - if ( !first ) - writer.println(" &"); - else - first = false; - - optional = method.getAnnotation(Optional.class) != null; - deprecated = method.getAnnotation(DeprecatedGL.class) != null; - dependent = method.getAnnotation(Dependent.class); - - writer.print("\t\t\t("); - if ( optional ) - writer.print('('); - if ( deprecated ) - writer.print("forwardCompatible || "); - if ( dependent != null ) { - if ( dependent.value().indexOf(',') == -1 ) - writer.print("!supported_extensions.contains(\"" + dependent.value() + "\") || "); - else { - writer.print("!(false"); - for ( String extension : dependent.value().split(",") ) - writer.print(" || supported_extensions.contains(\"" + extension + "\")"); - writer.print(") || "); - } - } - if ( deprecated || dependent != null ) - writer.print('('); - writer.print(Utils.getFunctionAddressName(d, method) + " = "); - PlatformDependent platform_dependent = method.getAnnotation(PlatformDependent.class); - if ( platform_dependent != null ) { - EnumSet platform_set = EnumSet.copyOf(Arrays.asList(platform_dependent.value())); - writer.print("GLContext.getPlatformSpecificFunctionAddress(\""); - writer.print(Platform.ALL.getPrefix() + "\", "); - writer.print("new String[]{"); - Iterator platforms = platform_set.iterator(); - while ( platforms.hasNext() ) { - writer.print("\"" + platforms.next().getOSPrefix() + "\""); - if ( platforms.hasNext() ) - writer.print(", "); - } - writer.print("}, new String[]{"); - platforms = platform_set.iterator(); - while ( platforms.hasNext() ) { - writer.print("\"" + platforms.next().getPrefix() + "\""); - if ( platforms.hasNext() ) - writer.print(", "); - } - writer.print("}, "); - } else if ( aliased ) { - writer.print("GLContext.getFunctionAddress(new String[] {\"" + method.getSimpleName() + "\",\"" + method.getSimpleName() + alias_annotation.postfix() + "\"})) != 0"); - } else - writer.print("GLContext.getFunctionAddress("); - if ( !aliased ) - writer.print("\"" + method.getSimpleName() + "\")) != 0"); - if ( deprecated || dependent != null ) - writer.print(')'); - if ( optional ) - writer.print(" || true)"); - } - writer.println(";"); - writer.println("\t}"); - writer.println(); - } - - public static void generateSymbolAddresses(PrintWriter writer, InterfaceDeclaration d) { - for ( MethodDeclaration method : d.getMethods() ) { - if ( method.getAnnotation(Alternate.class) == null ) - writer.println("\tlong " + Utils.getFunctionAddressName(d, method) + ";"); - } - } - - public static void generateField(PrintWriter writer, InterfaceDeclaration d) { - writer.println("\tpublic final boolean " + translateFieldName(d.getSimpleName()) + ";"); - } +/* + * 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 + * 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.generator.opengl; + +import org.lwjgl.util.generator.*; + +import java.io.PrintWriter; +import java.util.Arrays; +import java.util.Collection; +import java.util.EnumSet; +import java.util.Iterator; + +import com.sun.mirror.declaration.InterfaceDeclaration; +import com.sun.mirror.declaration.MethodDeclaration; +import com.sun.mirror.type.InterfaceType; + +/** + * Generator visitor for the context capabilities generator tool + * + * @author elias_naur + * @version $Revision: 3355 $ + * $Id: ContextCapabilitiesGenerator.java 3355 2010-05-27 22:56:29Z spasi $ + */ +public class GLCapabilitiesGenerator { + + private static final String STUBS_LOADED_NAME = "loaded_stubs"; + private static final String ALL_INIT_METHOD_NAME = "initAllStubs"; + private static final String POINTER_INITIALIZER_POSTFIX = "_initNativeFunctionAddresses"; + private static final String CACHED_EXTS_VAR_NAME = "supported_extensions"; + private static final String PROFILE_MASK_VAR_NAME = "profileMask"; + private static final String EXTENSION_PREFIX = "GL_"; + private static final String CORE_PREFIX = "Open"; + + 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 StateTracker tracker = new StateTracker();"); + writer.println(); + if ( !context_specific ) { + writer.println("\tprivate static boolean " + STUBS_LOADED_NAME + " = false;"); + } + } + + public static void generateInitializerPrologue(PrintWriter writer) { + writer.println("\t" + Utils.CONTEXT_CAPS_CLASS_NAME + "(boolean forwardCompatible) throws LWJGLException {"); + writer.println("\t\tSet " + CACHED_EXTS_VAR_NAME + " = " + ALL_INIT_METHOD_NAME + "(forwardCompatible);"); + } + + private static String translateFieldName(String interface_name) { + if ( interface_name.startsWith("GL") ) + return CORE_PREFIX + interface_name; + else + return EXTENSION_PREFIX + interface_name; + } + + public static void generateSuperClassAdds(PrintWriter writer, InterfaceDeclaration d) { + Collection super_interfaces = d.getSuperinterfaces(); + if ( super_interfaces.size() > 1 ) + throw new RuntimeException(d + " extends more than one other interface"); + if ( super_interfaces.size() == 1 ) { + InterfaceType super_interface = super_interfaces.iterator().next(); + writer.print("\t\tif (" + CACHED_EXTS_VAR_NAME + ".contains(\""); + writer.println(translateFieldName(d.getSimpleName()) + "\"))"); + writer.print("\t\t\t"); + generateAddExtension(writer, super_interface.getDeclaration()); + } + } + + public static void generateInitializer(PrintWriter writer, InterfaceDeclaration d) { + String translated_field_name = translateFieldName(d.getSimpleName()); + writer.print("\t\tthis." + translated_field_name + " = "); + writer.print(CACHED_EXTS_VAR_NAME + ".contains(\""); + writer.print(translated_field_name + "\")"); + Collection super_interfaces = d.getSuperinterfaces(); + if ( super_interfaces.size() > 1 ) + throw new RuntimeException(d + " extends more than one other interface"); + if ( super_interfaces.size() == 1 ) { + InterfaceType super_interface = super_interfaces.iterator().next(); + writer.println(); + writer.print("\t\t\t&& " + CACHED_EXTS_VAR_NAME + ".contains(\""); + writer.print(translateFieldName(super_interface.getDeclaration().getSimpleName()) + "\")"); + } + Alias alias_annotation = d.getAnnotation(Alias.class); + if ( alias_annotation != null ) { + writer.println(); + writer.print("\t\t\t|| " + CACHED_EXTS_VAR_NAME + ".contains(\""); + writer.print(translateFieldName(alias_annotation.value()) + "\")"); + } + writer.println(";"); + } + + private static String getAddressesInitializerName(String class_name) { + return class_name + POINTER_INITIALIZER_POSTFIX; + } + + public static void generateInitStubsPrologue(PrintWriter writer, boolean context_specific) { + writer.println("\tprivate Set " + ALL_INIT_METHOD_NAME + "(boolean forwardCompatible) throws LWJGLException {"); + + // Load the basic pointers we need to detect OpenGL version and supported extensions. + writer.println("\t\tglGetError = GLContext.getFunctionAddress(\"glGetError\");"); + writer.println("\t\tglGetString = GLContext.getFunctionAddress(\"glGetString\");"); + + // Initialize GL11.glGetIntegerv and GL30.glGetStringi here, in case we have created an OpenGL 3.0 context. + // (they will be used in GLContext.getSupportedExtensions) + writer.println("\t\tglGetIntegerv = GLContext.getFunctionAddress(\"glGetIntegerv\");"); + writer.println("\t\tglGetStringi = GLContext.getFunctionAddress(\"glGetStringi\");"); + + // Get the supported extensions set. + writer.println("\t\tGLContext.setCapabilities(this);"); + writer.println("\t\tSet " + CACHED_EXTS_VAR_NAME + " = new HashSet(256);"); + writer.println("\t\tint " + PROFILE_MASK_VAR_NAME + " = GLContext.getSupportedExtensions(" + CACHED_EXTS_VAR_NAME + ");"); + + // Force forward compatible mode when OpenGL version is 3.1 or higher and ARB_compatibility is not available. + writer.println("\t\tif ( supported_extensions.contains(\"OpenGL31\") && !(supported_extensions.contains(\"GL_ARB_compatibility\") || (profileMask & GL32.GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0) )"); + writer.println("\t\t\tforwardCompatible = true;"); + + if ( !context_specific ) { + writer.println("\t\tif (" + STUBS_LOADED_NAME + ")"); + writer.println("\t\t\treturn GLContext.getSupportedExtensions();"); + writer.println("\t\torg.lwjgl.opengl.GL11." + Utils.STUB_INITIALIZER_NAME + "();"); + } else { + writer.println("\t\tif (!" + getAddressesInitializerName("GL11") + "(forwardCompatible))"); + writer.println("\t\t\tthrow new LWJGLException(\"GL11 not supported\");"); + } + } + + public static void generateInitStubsEpilogue(PrintWriter writer, boolean context_specific) { + if ( !context_specific ) { + writer.println("\t\t" + STUBS_LOADED_NAME + " = true;"); + } + writer.println("\t\treturn " + CACHED_EXTS_VAR_NAME + ";"); + writer.println("\t}"); + } + + public static void generateUnloadStubs(PrintWriter writer, InterfaceDeclaration d) { + if ( d.getMethods().size() > 0 ) { + writer.print("\t\tGLContext.resetNativeStubs(" + Utils.getSimpleClassName(d)); + writer.println(".class);"); + } + } + + public static void generateInitStubs(PrintWriter writer, InterfaceDeclaration d, boolean context_specific) { + if ( d.getMethods().size() > 0 ) { + if ( context_specific ) { + final Alias alias_annotation = d.getAnnotation(Alias.class); + + if ( d.getAnnotation(ForceInit.class) != null ) + writer.println("\t\t" + CACHED_EXTS_VAR_NAME + ".add(\"" + translateFieldName(d.getSimpleName()) + "\");"); + writer.print("\t\tif ("); + if ( alias_annotation != null ) + writer.print("("); + writer.print(CACHED_EXTS_VAR_NAME + ".contains(\""); + writer.print(translateFieldName(d.getSimpleName()) + "\")"); + if ( alias_annotation != null ) { + writer.print(" || " + CACHED_EXTS_VAR_NAME + ".contains(\""); + writer.print(translateFieldName(alias_annotation.value()) + "\"))"); + } + writer.print(" && !" + getAddressesInitializerName(d.getSimpleName()) + "("); + if ( d.getAnnotation(DeprecatedGL.class) != null ) + writer.print("forwardCompatible"); + if ( d.getAnnotation(Dependent.class) != null ) { + if ( d.getAnnotation(DeprecatedGL.class) != null ) + writer.print(","); + writer.print("supported_extensions"); + } + if ( alias_annotation != null ) { + writer.println(")) {"); + writer.print("\t\t\tremove(" + CACHED_EXTS_VAR_NAME + ", \""); + writer.println(translateFieldName(alias_annotation.value()) + "\");"); + } else + writer.println("))"); + writer.print("\t\t\tremove(" + CACHED_EXTS_VAR_NAME + ", \""); + writer.println(translateFieldName(d.getSimpleName()) + "\");"); + if ( alias_annotation != null ) + writer.println("\t\t}"); + } else { + writer.print("\t\tGLContext." + Utils.STUB_INITIALIZER_NAME + "(" + Utils.getSimpleClassName(d)); + writer.println(".class, " + CACHED_EXTS_VAR_NAME + ", \"" + translateFieldName(d.getSimpleName()) + "\");"); + } + } + } + + private static void generateAddExtension(PrintWriter writer, InterfaceDeclaration d) { + writer.print(CACHED_EXTS_VAR_NAME + ".add(\""); + writer.println(translateFieldName(d.getSimpleName()) + "\");"); + } + + public static void generateAddressesInitializers(PrintWriter writer, InterfaceDeclaration d) { + Iterator methods = d.getMethods().iterator(); + if ( !methods.hasNext() ) + return; + + writer.print("\tprivate boolean " + getAddressesInitializerName(d.getSimpleName()) + "("); + + boolean optional; + boolean deprecated = d.getAnnotation(DeprecatedGL.class) != null; + Dependent dependent = d.getAnnotation(Dependent.class); + if ( deprecated ) + writer.print("boolean forwardCompatible"); + if ( dependent != null ) { + if ( deprecated ) + writer.print(","); + writer.print("Set supported_extensions"); + } + + Alias alias_annotation = d.getAnnotation(Alias.class); + boolean aliased = alias_annotation != null && alias_annotation.postfix().length() > 0; + + writer.println(") {"); + writer.println("\t\treturn "); + + boolean first = true; + while ( methods.hasNext() ) { + MethodDeclaration method = methods.next(); + if ( method.getAnnotation(Alternate.class) != null ) + continue; + + if ( !first ) + writer.println(" &"); + else + first = false; + + optional = method.getAnnotation(Optional.class) != null; + deprecated = method.getAnnotation(DeprecatedGL.class) != null; + dependent = method.getAnnotation(Dependent.class); + + writer.print("\t\t\t("); + if ( optional ) + writer.print('('); + if ( deprecated ) + writer.print("forwardCompatible || "); + if ( dependent != null ) { + if ( dependent.value().indexOf(',') == -1 ) + writer.print("!supported_extensions.contains(\"" + dependent.value() + "\") || "); + else { + writer.print("!(false"); + for ( String extension : dependent.value().split(",") ) + writer.print(" || supported_extensions.contains(\"" + extension + "\")"); + writer.print(") || "); + } + } + if ( deprecated || dependent != null ) + writer.print('('); + writer.print(Utils.getFunctionAddressName(d, method) + " = "); + PlatformDependent platform_dependent = method.getAnnotation(PlatformDependent.class); + if ( platform_dependent != null ) { + EnumSet platform_set = EnumSet.copyOf(Arrays.asList(platform_dependent.value())); + writer.print("GLContext.getPlatformSpecificFunctionAddress(\""); + writer.print(Platform.ALL.getPrefix() + "\", "); + writer.print("new String[]{"); + Iterator platforms = platform_set.iterator(); + while ( platforms.hasNext() ) { + writer.print("\"" + platforms.next().getOSPrefix() + "\""); + if ( platforms.hasNext() ) + writer.print(", "); + } + writer.print("}, new String[]{"); + platforms = platform_set.iterator(); + while ( platforms.hasNext() ) { + writer.print("\"" + platforms.next().getPrefix() + "\""); + if ( platforms.hasNext() ) + writer.print(", "); + } + writer.print("}, "); + } else if ( aliased ) { + writer.print("GLContext.getFunctionAddress(new String[] {\"" + method.getSimpleName() + "\",\"" + method.getSimpleName() + alias_annotation.postfix() + "\"})) != 0"); + } else + writer.print("GLContext.getFunctionAddress("); + if ( !aliased ) + writer.print("\"" + method.getSimpleName() + "\")) != 0"); + if ( deprecated || dependent != null ) + writer.print(')'); + if ( optional ) + writer.print(" || true)"); + } + writer.println(";"); + writer.println("\t}"); + writer.println(); + } + + public static void generateSymbolAddresses(PrintWriter writer, InterfaceDeclaration d) { + boolean first = true; + for ( final MethodDeclaration method : d.getMethods() ) { + if ( method.getAnnotation(Alternate.class) != null || method.getAnnotation(Reuse.class) != null ) + continue; + + if ( first ) { + writer.println("\t// " + d.getSimpleName()); + first = false; + } + writer.println("\tlong " + Utils.getFunctionAddressName(d, method) + ";"); + } + } + + public static void generateField(PrintWriter writer, InterfaceDeclaration d) { + writer.println("\tpublic final boolean " + translateFieldName(d.getSimpleName()) + ";"); + } } \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/ContextGeneratorProcessorFactory.java b/src/java/org/lwjgl/util/generator/opengl/GLGeneratorProcessorFactory.java similarity index 83% rename from src/java/org/lwjgl/util/generator/ContextGeneratorProcessorFactory.java rename to src/java/org/lwjgl/util/generator/opengl/GLGeneratorProcessorFactory.java index 2ae7936c..6e5dbea4 100644 --- a/src/java/org/lwjgl/util/generator/ContextGeneratorProcessorFactory.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLGeneratorProcessorFactory.java @@ -1,189 +1,189 @@ -/* - * 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 - * 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.generator; - -import static java.util.Collections.unmodifiableCollection; - -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Arrays; -import java.util.Collection; -import java.util.Map; -import java.util.Set; - -import com.sun.mirror.apt.AnnotationProcessor; -import com.sun.mirror.apt.AnnotationProcessorEnvironment; -import com.sun.mirror.apt.AnnotationProcessorFactory; -import com.sun.mirror.apt.AnnotationProcessors; -import com.sun.mirror.apt.Filer; -import com.sun.mirror.apt.RoundCompleteEvent; -import com.sun.mirror.apt.RoundCompleteListener; -import com.sun.mirror.declaration.AnnotationTypeDeclaration; -import com.sun.mirror.declaration.InterfaceDeclaration; -import com.sun.mirror.declaration.TypeDeclaration; -import com.sun.mirror.util.DeclarationFilter; - -/** - * - * Generator tool for creating the ContexCapabilities class - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ -public class ContextGeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener { - private static boolean first_round = true; - - // Process any set of annotations - private static final Collection supportedAnnotations = - unmodifiableCollection(Arrays.asList("*")); - - public Collection supportedAnnotationTypes() { - return supportedAnnotations; - } - - public Collection supportedOptions() { - return unmodifiableCollection(Arrays.asList("-Acontextspecific", "-Ageneratechecks")); - } - - public void roundComplete(RoundCompleteEvent event) { - first_round = false; - } - - public AnnotationProcessor getProcessorFor(Set atds, AnnotationProcessorEnvironment env) { - // Only process the initial types, not the generated ones - if (first_round) { - env.addListener(this); - return new GeneratorProcessor(env); - } else - return AnnotationProcessors.NO_OP; - } - - private static class GeneratorProcessor implements AnnotationProcessor { - private final AnnotationProcessorEnvironment env; - - GeneratorProcessor(AnnotationProcessorEnvironment env) { - this.env = env; - } - - public void process() { - Map options = env.getOptions(); - boolean generate_error_checks = options.containsKey("-Ageneratechecks"); - boolean context_specific = options.containsKey("-Acontextspecific"); - try { - generateContextCapabilitiesSource(context_specific, generate_error_checks); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - private void generateContextCapabilitiesSource(boolean context_specific, boolean generate_error_checks) throws IOException { - PrintWriter writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "org.lwjgl.opengl", new File(Utils.CONTEXT_CAPS_CLASS_NAME + ".java"), null); - writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */"); - writer.println(); - writer.println("package org.lwjgl.opengl;"); - writer.println(); - writer.println("import org.lwjgl.LWJGLException;"); - writer.println("import org.lwjgl.LWJGLUtil;"); - writer.println("import org.lwjgl.BufferUtils;"); - writer.println("import java.util.Set;"); - writer.println("import java.util.HashSet;"); - writer.println("import java.nio.IntBuffer;"); - writer.println(); - ContextCapabilitiesGenerator.generateClassPrologue(writer, context_specific, generate_error_checks); - DeclarationFilter filter = DeclarationFilter.getFilter(InterfaceDeclaration.class); - Collection interface_decls = filter.filter(env.getSpecifiedTypeDeclarations()); - for (TypeDeclaration typedecl : interface_decls) { - InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; - if (Utils.isFinal(interface_decl)) - ContextCapabilitiesGenerator.generateField(writer, interface_decl); - } - writer.println(); - for (TypeDeclaration typedecl : interface_decls) { - InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; - ContextCapabilitiesGenerator.generateSymbolAddresses(writer, interface_decl); - } - writer.println(); - if (context_specific) { - for (TypeDeclaration typedecl : interface_decls) { - InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; - ContextCapabilitiesGenerator.generateAddressesInitializers(writer, interface_decl); - } - writer.println(); - } - - writer.println("\tprivate static void remove(Set supported_extensions, String extension) {"); - writer.println("\t\tLWJGLUtil.log(extension + \" was reported as available but an entry point is missing\");"); - writer.println("\t\tsupported_extensions.remove(extension);"); - writer.println("\t}\n"); - - ContextCapabilitiesGenerator.generateInitStubsPrologue(writer, context_specific); - for (TypeDeclaration typedecl : interface_decls) { - InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; - ContextCapabilitiesGenerator.generateSuperClassAdds(writer, interface_decl); - } - for (TypeDeclaration typedecl : interface_decls) { - InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; - String simple_name = interface_decl.getSimpleName(); - if (simple_name.equals("GL11")) - continue; - ContextCapabilitiesGenerator.generateInitStubs(writer, interface_decl, context_specific); - } - ContextCapabilitiesGenerator.generateInitStubsEpilogue(writer, context_specific); - writer.println(); - writer.println("\tstatic void unloadAllStubs() {"); - if (!context_specific) { - writer.println("\t\tif (!loaded_stubs)"); - writer.println("\t\t\treturn;"); - for (TypeDeclaration typedecl : interface_decls) { - InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; - ContextCapabilitiesGenerator.generateUnloadStubs(writer, interface_decl); - } - writer.println("\t\tloaded_stubs = false;"); - } - writer.println("\t}"); - writer.println(); - ContextCapabilitiesGenerator.generateInitializerPrologue(writer); - for (TypeDeclaration typedecl : interface_decls) { - InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; - if (Utils.isFinal(interface_decl)) - ContextCapabilitiesGenerator.generateInitializer(writer, interface_decl); - } - writer.println("\t\ttracker.init();"); - writer.println("\t}"); - writer.println("}"); - writer.close(); - } - } -} +/* + * 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 + * 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.generator.opengl; + +import org.lwjgl.util.generator.Utils; + +import static java.util.Collections.unmodifiableCollection; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Arrays; +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +import com.sun.mirror.apt.AnnotationProcessor; +import com.sun.mirror.apt.AnnotationProcessorEnvironment; +import com.sun.mirror.apt.AnnotationProcessorFactory; +import com.sun.mirror.apt.AnnotationProcessors; +import com.sun.mirror.apt.Filer; +import com.sun.mirror.apt.RoundCompleteEvent; +import com.sun.mirror.apt.RoundCompleteListener; +import com.sun.mirror.declaration.AnnotationTypeDeclaration; +import com.sun.mirror.declaration.InterfaceDeclaration; +import com.sun.mirror.declaration.TypeDeclaration; +import com.sun.mirror.util.DeclarationFilter; + +/** + * + * Generator tool for creating the ContexCapabilities class + * + * @author elias_naur + * @version $Revision: 3316 $ + * $Id: ContextGeneratorProcessorFactory.java 3316 2010-04-09 23:57:40Z spasi $ + */ +public class GLGeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener { + private static boolean first_round = true; + + // Process any set of annotations + private static final Collection supportedAnnotations = + unmodifiableCollection(Arrays.asList("*")); + + public Collection supportedAnnotationTypes() { + return supportedAnnotations; + } + + public Collection supportedOptions() { + return unmodifiableCollection(Arrays.asList("-Acontextspecific", "-Ageneratechecks")); + } + + public void roundComplete(RoundCompleteEvent event) { + first_round = false; + } + + public AnnotationProcessor getProcessorFor(Set atds, AnnotationProcessorEnvironment env) { + // Only process the initial types, not the generated ones + if (first_round) { + env.addListener(this); + return new GeneratorProcessor(env); + } else + return AnnotationProcessors.NO_OP; + } + + private static class GeneratorProcessor implements AnnotationProcessor { + private final AnnotationProcessorEnvironment env; + + GeneratorProcessor(AnnotationProcessorEnvironment env) { + this.env = env; + } + + public void process() { + Map options = env.getOptions(); + boolean generate_error_checks = options.containsKey("-Ageneratechecks"); + boolean context_specific = options.containsKey("-Acontextspecific"); + try { + generateContextCapabilitiesSource(context_specific, generate_error_checks); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + private void generateContextCapabilitiesSource(boolean context_specific, boolean generate_error_checks) throws IOException { + PrintWriter writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "org.lwjgl.opengl", new File(Utils.CONTEXT_CAPS_CLASS_NAME + ".java"), null); + writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */"); + writer.println(); + writer.println("package org.lwjgl.opengl;"); + writer.println(); + writer.println("import org.lwjgl.LWJGLException;"); + writer.println("import org.lwjgl.LWJGLUtil;"); + writer.println("import java.util.Set;"); + writer.println("import java.util.HashSet;"); + writer.println(); + GLCapabilitiesGenerator.generateClassPrologue(writer, context_specific, generate_error_checks); + DeclarationFilter filter = DeclarationFilter.getFilter(InterfaceDeclaration.class); + Collection interface_decls = filter.filter(env.getSpecifiedTypeDeclarations()); + for (TypeDeclaration typedecl : interface_decls) { + InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; + if (Utils.isFinal(interface_decl)) + GLCapabilitiesGenerator.generateField(writer, interface_decl); + } + writer.println(); + for (TypeDeclaration typedecl : interface_decls) { + InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; + GLCapabilitiesGenerator.generateSymbolAddresses(writer, interface_decl); + } + writer.println(); + if (context_specific) { + for (TypeDeclaration typedecl : interface_decls) { + InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; + GLCapabilitiesGenerator.generateAddressesInitializers(writer, interface_decl); + } + writer.println(); + } + + writer.println("\tprivate static void remove(Set supported_extensions, String extension) {"); + writer.println("\t\tLWJGLUtil.log(extension + \" was reported as available but an entry point is missing\");"); + writer.println("\t\tsupported_extensions.remove(extension);"); + writer.println("\t}\n"); + + GLCapabilitiesGenerator.generateInitStubsPrologue(writer, context_specific); + for (TypeDeclaration typedecl : interface_decls) { + InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; + GLCapabilitiesGenerator.generateSuperClassAdds(writer, interface_decl); + } + for (TypeDeclaration typedecl : interface_decls) { + InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; + String simple_name = interface_decl.getSimpleName(); + if (simple_name.equals("GL11")) + continue; + GLCapabilitiesGenerator.generateInitStubs(writer, interface_decl, context_specific); + } + GLCapabilitiesGenerator.generateInitStubsEpilogue(writer, context_specific); + writer.println(); + writer.println("\tstatic void unloadAllStubs() {"); + if (!context_specific) { + writer.println("\t\tif (!loaded_stubs)"); + writer.println("\t\t\treturn;"); + for (TypeDeclaration typedecl : interface_decls) { + InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; + GLCapabilitiesGenerator.generateUnloadStubs(writer, interface_decl); + } + writer.println("\t\tloaded_stubs = false;"); + } + writer.println("\t}"); + writer.println(); + GLCapabilitiesGenerator.generateInitializerPrologue(writer); + for (TypeDeclaration typedecl : interface_decls) { + InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; + if (Utils.isFinal(interface_decl)) + GLCapabilitiesGenerator.generateInitializer(writer, interface_decl); + } + writer.println("\t\ttracker.init();"); + writer.println("\t}"); + writer.println("}"); + writer.close(); + } + } +} diff --git a/src/java/org/lwjgl/util/generator/ReferencesGeneratorProcessorFactory.java b/src/java/org/lwjgl/util/generator/opengl/GLReferencesGeneratorProcessorFactory.java similarity index 93% rename from src/java/org/lwjgl/util/generator/ReferencesGeneratorProcessorFactory.java rename to src/java/org/lwjgl/util/generator/opengl/GLReferencesGeneratorProcessorFactory.java index c1f9eee7..f306603e 100644 --- a/src/java/org/lwjgl/util/generator/ReferencesGeneratorProcessorFactory.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLReferencesGeneratorProcessorFactory.java @@ -1,205 +1,208 @@ -/* - * 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 - * 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.generator; - -import static java.util.Collections.emptyList; -import static java.util.Collections.unmodifiableCollection; - -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Arrays; -import java.util.Collection; -import java.util.Set; - -import com.sun.mirror.apt.AnnotationProcessor; -import com.sun.mirror.apt.AnnotationProcessorEnvironment; -import com.sun.mirror.apt.AnnotationProcessorFactory; -import com.sun.mirror.apt.AnnotationProcessors; -import com.sun.mirror.apt.Filer; -import com.sun.mirror.apt.RoundCompleteEvent; -import com.sun.mirror.apt.RoundCompleteListener; -import com.sun.mirror.declaration.AnnotationTypeDeclaration; -import com.sun.mirror.declaration.InterfaceDeclaration; -import com.sun.mirror.declaration.MethodDeclaration; -import com.sun.mirror.declaration.ParameterDeclaration; -import com.sun.mirror.declaration.TypeDeclaration; -import com.sun.mirror.util.DeclarationFilter; - -/** - * - * Generator tool for creating the References class - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ -public class ReferencesGeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener { - private final static String REFERENCES_CLASS_NAME = "References"; - private final static String REFERENCES_PARAMETER_NAME = "references"; - - private static boolean first_round = true; - - // Process any set of annotations - private static final Collection supportedAnnotations = - unmodifiableCollection(Arrays.asList("*")); - - public Collection supportedAnnotationTypes() { - return supportedAnnotations; - } - - public Collection supportedOptions() { - return emptyList(); - } - - public void roundComplete(RoundCompleteEvent event) { - first_round = false; - } - - public AnnotationProcessor getProcessorFor(Set atds, AnnotationProcessorEnvironment env) { - // Only process the initial types, not the generated ones - if (first_round) { - env.addListener(this); - return new GeneratorProcessor(env); - } else - return AnnotationProcessors.NO_OP; - } - - private static class GeneratorProcessor implements AnnotationProcessor { - private final AnnotationProcessorEnvironment env; - - GeneratorProcessor(AnnotationProcessorEnvironment env) { - this.env = env; - } - - public void process() { - try { - generateReferencesSource(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - private static void generateClearsFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) { - for (ParameterDeclaration param : method.getParameters()) { - CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class); - if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) { - Class nio_type = Utils.getNIOBufferType(param.getType()); - String reference_name = Utils.getReferenceName(interface_decl, method, param); - writer.println("\t\tthis." + reference_name + " = null;"); - } - } - } - - private static void generateCopiesFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) { - for (ParameterDeclaration param : method.getParameters()) { - CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class); - if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) { - Class nio_type = Utils.getNIOBufferType(param.getType()); - String reference_name = Utils.getReferenceName(interface_decl, method, param); - writer.print("\t\t\tthis." + reference_name + " = "); - writer.println(REFERENCES_PARAMETER_NAME + "." + reference_name + ";"); - } - } - } - - private static void generateClearsFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) { - for (MethodDeclaration method : interface_decl.getMethods()) { - generateClearsFromParameters(writer, interface_decl, method); - } - } - - private static void generateCopiesFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) { - for (MethodDeclaration method : interface_decl.getMethods()) { - generateCopiesFromParameters(writer, interface_decl, method); - } - } - - private static void generateReferencesFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) { - for (ParameterDeclaration param : method.getParameters()) { - CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class); - if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) { - Class nio_type = Utils.getNIOBufferType(param.getType()); - if (nio_type == null) - throw new RuntimeException(param + " in method " + method + " in " + interface_decl + " is annotated with " - + cached_reference_annotation.annotationType().getSimpleName() + " but the parameter is not a NIO buffer"); - writer.print("\t" + nio_type.getName() + " " + Utils.getReferenceName(interface_decl, method, param)); - writer.println(";"); - } - } - } - - private static void generateReferencesFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) { - for (MethodDeclaration method : interface_decl.getMethods()) { - generateReferencesFromParameters(writer, interface_decl, method); - } - } - - private void generateReferencesSource() throws IOException { - PrintWriter writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "org.lwjgl.opengl", new File(REFERENCES_CLASS_NAME + ".java"), null); - writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */"); - writer.println(); - writer.println("package org.lwjgl.opengl;"); - writer.println(); - writer.println("class " + REFERENCES_CLASS_NAME + " extends BaseReferences {"); - writer.println("\t" + REFERENCES_CLASS_NAME + "(ContextCapabilities caps) {"); - writer.println("\t\tsuper(caps);"); - writer.println("\t}"); - DeclarationFilter filter = DeclarationFilter.getFilter(InterfaceDeclaration.class); - Collection interface_decls = filter.filter(env.getSpecifiedTypeDeclarations()); - for (TypeDeclaration typedecl : interface_decls) { - InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; - generateReferencesFromMethods(writer, interface_decl); - } - writer.println(); - writer.println("\tvoid copy(" + REFERENCES_CLASS_NAME + " " + REFERENCES_PARAMETER_NAME + ", int mask) {"); - writer.println("\t\tsuper.copy(" + REFERENCES_PARAMETER_NAME + ", mask);"); - writer.println("\t\tif ( (mask & GL11.GL_CLIENT_VERTEX_ARRAY_BIT) != 0 ) {"); - for (TypeDeclaration typedecl : interface_decls) { - InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; - generateCopiesFromMethods(writer, interface_decl); - } - writer.println("\t\t}"); - writer.println("\t}"); - writer.println("\tvoid clear() {"); - writer.println("\t\tsuper.clear();"); - for (TypeDeclaration typedecl : interface_decls) { - InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; - generateClearsFromMethods(writer, interface_decl); - } - writer.println("\t}"); - writer.println("}"); - writer.close(); - } - } -} +/* + * 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 + * 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.generator.opengl; + +import org.lwjgl.util.generator.CachedReference; +import org.lwjgl.util.generator.Utils; + +import static java.util.Collections.emptyList; +import static java.util.Collections.unmodifiableCollection; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Arrays; +import java.util.Collection; +import java.util.Set; + +import com.sun.mirror.apt.AnnotationProcessor; +import com.sun.mirror.apt.AnnotationProcessorEnvironment; +import com.sun.mirror.apt.AnnotationProcessorFactory; +import com.sun.mirror.apt.AnnotationProcessors; +import com.sun.mirror.apt.Filer; +import com.sun.mirror.apt.RoundCompleteEvent; +import com.sun.mirror.apt.RoundCompleteListener; +import com.sun.mirror.declaration.AnnotationTypeDeclaration; +import com.sun.mirror.declaration.InterfaceDeclaration; +import com.sun.mirror.declaration.MethodDeclaration; +import com.sun.mirror.declaration.ParameterDeclaration; +import com.sun.mirror.declaration.TypeDeclaration; +import com.sun.mirror.util.DeclarationFilter; + +/** + * + * Generator tool for creating the References class + * + * @author elias_naur + * @version $Revision: 3237 $ + * $Id: ReferencesGeneratorProcessorFactory.java 3237 2009-09-08 15:07:15Z spasi $ + */ +public class GLReferencesGeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener { + private final static String REFERENCES_CLASS_NAME = "References"; + private final static String REFERENCES_PARAMETER_NAME = "references"; + + private static boolean first_round = true; + + // Process any set of annotations + private static final Collection supportedAnnotations = + unmodifiableCollection(Arrays.asList("*")); + + public Collection supportedAnnotationTypes() { + return supportedAnnotations; + } + + public Collection supportedOptions() { + return emptyList(); + } + + public void roundComplete(RoundCompleteEvent event) { + first_round = false; + } + + public AnnotationProcessor getProcessorFor(Set atds, AnnotationProcessorEnvironment env) { + // Only process the initial types, not the generated ones + if (first_round) { + env.addListener(this); + return new GeneratorProcessor(env); + } else + return AnnotationProcessors.NO_OP; + } + + private static class GeneratorProcessor implements AnnotationProcessor { + private final AnnotationProcessorEnvironment env; + + GeneratorProcessor(AnnotationProcessorEnvironment env) { + this.env = env; + } + + public void process() { + try { + generateReferencesSource(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + private static void generateClearsFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) { + for (ParameterDeclaration param : method.getParameters()) { + CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class); + if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) { + Class nio_type = Utils.getNIOBufferType(param.getType()); + String reference_name = Utils.getReferenceName(interface_decl, method, param); + writer.println("\t\tthis." + reference_name + " = null;"); + } + } + } + + private static void generateCopiesFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) { + for (ParameterDeclaration param : method.getParameters()) { + CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class); + if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) { + Class nio_type = Utils.getNIOBufferType(param.getType()); + String reference_name = Utils.getReferenceName(interface_decl, method, param); + writer.print("\t\t\tthis." + reference_name + " = "); + writer.println(REFERENCES_PARAMETER_NAME + "." + reference_name + ";"); + } + } + } + + private static void generateClearsFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) { + for (MethodDeclaration method : interface_decl.getMethods()) { + generateClearsFromParameters(writer, interface_decl, method); + } + } + + private static void generateCopiesFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) { + for (MethodDeclaration method : interface_decl.getMethods()) { + generateCopiesFromParameters(writer, interface_decl, method); + } + } + + private static void generateReferencesFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) { + for (ParameterDeclaration param : method.getParameters()) { + CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class); + if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) { + Class nio_type = Utils.getNIOBufferType(param.getType()); + if (nio_type == null) + throw new RuntimeException(param + " in method " + method + " in " + interface_decl + " is annotated with " + + cached_reference_annotation.annotationType().getSimpleName() + " but the parameter is not a NIO buffer"); + writer.print("\t" + nio_type.getName() + " " + Utils.getReferenceName(interface_decl, method, param)); + writer.println(";"); + } + } + } + + private static void generateReferencesFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) { + for (MethodDeclaration method : interface_decl.getMethods()) { + generateReferencesFromParameters(writer, interface_decl, method); + } + } + + private void generateReferencesSource() throws IOException { + PrintWriter writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "org.lwjgl.opengl", new File(REFERENCES_CLASS_NAME + ".java"), null); + writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */"); + writer.println(); + writer.println("package org.lwjgl.opengl;"); + writer.println(); + writer.println("class " + REFERENCES_CLASS_NAME + " extends BaseReferences {"); + writer.println("\t" + REFERENCES_CLASS_NAME + "(ContextCapabilities caps) {"); + writer.println("\t\tsuper(caps);"); + writer.println("\t}"); + DeclarationFilter filter = DeclarationFilter.getFilter(InterfaceDeclaration.class); + Collection interface_decls = filter.filter(env.getSpecifiedTypeDeclarations()); + for (TypeDeclaration typedecl : interface_decls) { + InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; + generateReferencesFromMethods(writer, interface_decl); + } + writer.println(); + writer.println("\tvoid copy(" + REFERENCES_CLASS_NAME + " " + REFERENCES_PARAMETER_NAME + ", int mask) {"); + writer.println("\t\tsuper.copy(" + REFERENCES_PARAMETER_NAME + ", mask);"); + writer.println("\t\tif ( (mask & GL11.GL_CLIENT_VERTEX_ARRAY_BIT) != 0 ) {"); + for (TypeDeclaration typedecl : interface_decls) { + InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; + generateCopiesFromMethods(writer, interface_decl); + } + writer.println("\t\t}"); + writer.println("\t}"); + writer.println("\tvoid clear() {"); + writer.println("\t\tsuper.clear();"); + for (TypeDeclaration typedecl : interface_decls) { + InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; + generateClearsFromMethods(writer, interface_decl); + } + writer.println("\t}"); + writer.println("}"); + writer.close(); + } + } +} diff --git a/src/java/org/lwjgl/util/generator/GLTypeMap.java b/src/java/org/lwjgl/util/generator/opengl/GLTypeMap.java similarity index 86% rename from src/java/org/lwjgl/util/generator/GLTypeMap.java rename to src/java/org/lwjgl/util/generator/opengl/GLTypeMap.java index 7e466442..92f6df1f 100644 --- a/src/java/org/lwjgl/util/generator/GLTypeMap.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLTypeMap.java @@ -1,299 +1,324 @@ -/* - * 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 - * 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.generator; - -/** - * - * OpenGL sepcific generator behaviour - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import org.lwjgl.opengl.PointerWrapper; - -import java.io.PrintWriter; -import java.nio.*; -import java.util.HashMap; -import java.util.Map; - -import com.sun.mirror.declaration.AnnotationMirror; -import com.sun.mirror.type.PrimitiveType; - -public class GLTypeMap implements TypeMap { - - private static final Map native_types_to_primitive; - - static { - native_types_to_primitive = new HashMap(); - native_types_to_primitive.put(GLbitfield.class, PrimitiveType.Kind.INT); - native_types_to_primitive.put(GLcharARB.class, PrimitiveType.Kind.BYTE); - native_types_to_primitive.put(GLclampf.class, PrimitiveType.Kind.FLOAT); - native_types_to_primitive.put(GLfloat.class, PrimitiveType.Kind.FLOAT); - native_types_to_primitive.put(GLint.class, PrimitiveType.Kind.INT); - native_types_to_primitive.put(GLshort.class, PrimitiveType.Kind.SHORT); - native_types_to_primitive.put(GLsizeiptr.class, PrimitiveType.Kind.LONG); - native_types_to_primitive.put(GLuint.class, PrimitiveType.Kind.INT); - native_types_to_primitive.put(GLboolean.class, PrimitiveType.Kind.BOOLEAN); - native_types_to_primitive.put(GLchar.class, PrimitiveType.Kind.BYTE); - native_types_to_primitive.put(GLdouble.class, PrimitiveType.Kind.DOUBLE); - native_types_to_primitive.put(GLhalf.class, PrimitiveType.Kind.SHORT); - native_types_to_primitive.put(GLintptrARB.class, PrimitiveType.Kind.LONG); - native_types_to_primitive.put(GLsizei.class, PrimitiveType.Kind.INT); - native_types_to_primitive.put(GLushort.class, PrimitiveType.Kind.SHORT); - native_types_to_primitive.put(GLbyte.class, PrimitiveType.Kind.BYTE); - native_types_to_primitive.put(GLclampd.class, PrimitiveType.Kind.DOUBLE); - native_types_to_primitive.put(GLenum.class, PrimitiveType.Kind.INT); - native_types_to_primitive.put(GLhandleARB.class, PrimitiveType.Kind.INT); - native_types_to_primitive.put(GLintptr.class, PrimitiveType.Kind.LONG); - native_types_to_primitive.put(GLsizeiptrARB.class, PrimitiveType.Kind.LONG); - native_types_to_primitive.put(GLubyte.class, PrimitiveType.Kind.BYTE); - native_types_to_primitive.put(GLvoid.class, PrimitiveType.Kind.BYTE); - native_types_to_primitive.put(GLint64EXT.class, PrimitiveType.Kind.LONG); - native_types_to_primitive.put(GLuint64EXT.class, PrimitiveType.Kind.LONG); - native_types_to_primitive.put(GLint64.class, PrimitiveType.Kind.LONG); - native_types_to_primitive.put(GLuint64.class, PrimitiveType.Kind.LONG); - } - - public PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type) { - PrimitiveType.Kind kind = native_types_to_primitive.get(native_type); - if ( kind == null ) - throw new RuntimeException("Unsupported type " + native_type); - return kind; - } - - public String getErrorCheckMethodName() { - return "Util.checkGLError()"; - } - - public String getRegisterNativesFunctionName() { - return "extgl_InitializeClass"; - } - - public Signedness getSignednessFromType(Class type) { - if ( GLuint.class.equals(type) ) - return Signedness.UNSIGNED; - else if ( GLint.class.equals(type) ) - return Signedness.SIGNED; - else if ( GLushort.class.equals(type) ) - return Signedness.UNSIGNED; - else if ( GLshort.class.equals(type) ) - return Signedness.SIGNED; - else if ( GLubyte.class.equals(type) ) - return Signedness.UNSIGNED; - else if ( GLbyte.class.equals(type) ) - return Signedness.SIGNED; - else if ( GLuint64EXT.class.equals(type) ) - return Signedness.UNSIGNED; - else if ( GLint64EXT.class.equals(type) ) - return Signedness.SIGNED; - else if ( GLuint64.class.equals(type) ) - return Signedness.UNSIGNED; - else if ( GLint64.class.equals(type) ) - return Signedness.SIGNED; - else - return Signedness.NONE; - } - - public String translateAnnotation(Class annotation_type) { - if ( annotation_type.equals(GLuint.class) || annotation_type.equals(GLint.class) ) - return "i"; - else if ( annotation_type.equals(GLushort.class) || annotation_type.equals(GLshort.class) ) - return "s"; - else if ( annotation_type.equals(GLubyte.class) || annotation_type.equals(GLbyte.class) ) - return "b"; - else if ( annotation_type.equals(GLfloat.class) || annotation_type.equals(GLclampf.class) ) - return "f"; - else if ( annotation_type.equals(GLdouble.class) || annotation_type.equals(GLclampd.class) ) - return "d"; - else if ( annotation_type.equals(GLhalf.class) ) - return "h"; - else if ( annotation_type.equals(GLuint64EXT.class) || annotation_type.equals(GLint64EXT.class) || annotation_type.equals(GLuint64.class) || annotation_type.equals(GLint64.class) ) - return "i64"; - else if ( annotation_type.equals(GLboolean.class) || annotation_type.equals(GLvoid.class) ) - return ""; - else - throw new RuntimeException(annotation_type + " is not allowed"); - } - - public Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind) { - Class type; - switch ( kind ) { - case INT: - type = GLint.class; - break; - case DOUBLE: - type = GLdouble.class; - break; - case FLOAT: - type = GLfloat.class; - break; - case SHORT: - type = GLshort.class; - break; - case BYTE: - type = GLbyte.class; - break; - case LONG: - type = GLint64EXT.class; - break; - case BOOLEAN: - type = GLboolean.class; - break; - default: - throw new RuntimeException(kind + " is not allowed"); - } - return type; - } - - public Class getVoidType() { - return GLvoid.class; - } - - public Class getStringElementType() { - return GLubyte.class; - } - - private static Class[] getValidBufferTypes(Class type) { - if ( type.equals(IntBuffer.class) ) - return new Class[] { GLbitfield.class, GLenum.class, GLhandleARB.class, GLint.class, - GLsizei.class, GLuint.class, GLvoid.class }; - else if ( type.equals(FloatBuffer.class) ) - return new Class[] { GLclampf.class, GLfloat.class }; - else if ( type.equals(ByteBuffer.class) ) - return new Class[] { GLboolean.class, GLbyte.class, GLcharARB.class, GLchar.class, GLubyte.class, GLvoid.class }; - else if ( type.equals(ShortBuffer.class) ) - return new Class[] { GLhalf.class, GLshort.class, GLushort.class }; - else if ( type.equals(DoubleBuffer.class) ) - return new Class[] { GLclampd.class, GLdouble.class }; - else if ( type.equals(LongBuffer.class) ) - return new Class[] { GLint64EXT.class, GLuint64EXT.class, GLint64.class, GLuint64.class }; - else - return new Class[] { }; - } - - private static Class[] getValidPrimitiveTypes(Class type) { - if ( type.equals(long.class) ) - return new Class[] { GLintptrARB.class, GLuint.class, GLintptr.class, GLsizeiptrARB.class, GLsizeiptr.class, GLint64EXT.class, GLuint64EXT.class, GLint64.class, GLuint64.class }; - else if ( type.equals(int.class) ) - return new Class[] { GLbitfield.class, GLenum.class, GLhandleARB.class, GLint.class, GLuint.class, - GLsizei.class }; - else if ( type.equals(double.class) ) - return new Class[] { GLclampd.class, GLdouble.class }; - else if ( type.equals(float.class) ) - return new Class[] { GLclampf.class, GLfloat.class }; - else if ( type.equals(short.class) ) - return new Class[] { GLhalf.class, GLshort.class, GLushort.class }; - else if ( type.equals(byte.class) ) - return new Class[] { GLbyte.class, GLcharARB.class, GLchar.class, GLubyte.class }; - else if ( type.equals(boolean.class) ) - return new Class[] { GLboolean.class }; - else if ( type.equals(void.class) ) - return new Class[] { GLvoid.class, GLreturn.class }; - else - return new Class[] { }; - } - - public String getTypedefPrefix() { - return "APIENTRY"; - } - - public void printNativeIncludes(PrintWriter writer) { - writer.println("#include \"extgl.h\""); - } - - public Class[] getValidAnnotationTypes(Class type) { - Class[] valid_types; - if ( Buffer.class.isAssignableFrom(type) ) - valid_types = getValidBufferTypes(type); - else if ( type.isPrimitive() ) - valid_types = getValidPrimitiveTypes(type); - else if ( String.class.equals(type) ) - valid_types = new Class[] { GLubyte.class }; - else if ( PointerWrapper.class.isAssignableFrom(type) ) - valid_types = new Class[] { GLpointer.class }; - else if (void.class.equals(type) ) - valid_types = new Class[] { GLreturn.class }; - else - valid_types = new Class[] { }; - return valid_types; - } - - public Class getInverseType(Class type) { - if ( GLuint.class.equals(type) ) - return GLint.class; - else if ( GLint.class.equals(type) ) - return GLuint.class; - else if ( GLushort.class.equals(type) ) - return GLshort.class; - else if ( GLshort.class.equals(type) ) - return GLushort.class; - else if ( GLubyte.class.equals(type) ) - return GLbyte.class; - else if ( GLbyte.class.equals(type) ) - return GLubyte.class; - else if ( GLuint64EXT.class.equals(type) ) - return GLint64EXT.class; - else if ( GLint64EXT.class.equals(type) ) - return GLuint64EXT.class; - else if ( GLuint64.class.equals(type) ) - return GLint64.class; - else if ( GLint64.class.equals(type) ) - return GLuint64.class; - else - return null; - } - - public String getAutoTypeFromAnnotation(AnnotationMirror annotation) { - Class annotation_class = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType()); - if ( annotation_class.equals(GLint.class) ) - return "GL11.GL_INT"; - else if ( annotation_class.equals(GLbyte.class) ) - return "GL11.GL_BYTE"; - else if ( annotation_class.equals(GLshort.class) ) - return "GL11.GL_SHORT"; - if ( annotation_class.equals(GLuint.class) ) - return "GL11.GL_UNSIGNED_INT"; - else if ( annotation_class.equals(GLubyte.class) ) - return "GL11.GL_UNSIGNED_BYTE"; - else if ( annotation_class.equals(GLushort.class) ) - return "GL11.GL_UNSIGNED_SHORT"; - else if ( annotation_class.equals(GLfloat.class) ) - return "GL11.GL_FLOAT"; - else if ( annotation_class.equals(GLdouble.class) ) - return "GL11.GL_DOUBLE"; - else - return null; - } -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * OpenGL sepcific generator behaviour + * + * @author elias_naur + * @version $Revision: 3392 $ + * $Id: GLTypeMap.java 3392 2010-07-27 15:33:22Z spasi $ + */ + +import org.lwjgl.util.generator.NativeTypeTranslator; +import org.lwjgl.util.generator.PointerWrapper; +import org.lwjgl.util.generator.Signedness; +import org.lwjgl.util.generator.TypeMap; + +import java.io.PrintWriter; +import java.lang.annotation.Annotation; +import java.nio.*; +import java.util.HashMap; +import java.util.Map; + +import com.sun.mirror.declaration.AnnotationMirror; +import com.sun.mirror.declaration.MethodDeclaration; +import com.sun.mirror.type.PrimitiveType; + +public class GLTypeMap implements TypeMap { + + private static final Map native_types_to_primitive; + + static { + native_types_to_primitive = new HashMap(); + native_types_to_primitive.put(GLbitfield.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(GLcharARB.class, PrimitiveType.Kind.BYTE); + native_types_to_primitive.put(GLclampf.class, PrimitiveType.Kind.FLOAT); + native_types_to_primitive.put(GLfloat.class, PrimitiveType.Kind.FLOAT); + native_types_to_primitive.put(GLint.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(GLshort.class, PrimitiveType.Kind.SHORT); + native_types_to_primitive.put(GLsizeiptr.class, PrimitiveType.Kind.LONG); + native_types_to_primitive.put(GLuint.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(GLboolean.class, PrimitiveType.Kind.BOOLEAN); + native_types_to_primitive.put(GLchar.class, PrimitiveType.Kind.BYTE); + native_types_to_primitive.put(GLdouble.class, PrimitiveType.Kind.DOUBLE); + native_types_to_primitive.put(GLhalf.class, PrimitiveType.Kind.SHORT); + native_types_to_primitive.put(GLintptrARB.class, PrimitiveType.Kind.LONG); + native_types_to_primitive.put(GLsizei.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(GLushort.class, PrimitiveType.Kind.SHORT); + native_types_to_primitive.put(GLbyte.class, PrimitiveType.Kind.BYTE); + native_types_to_primitive.put(GLclampd.class, PrimitiveType.Kind.DOUBLE); + native_types_to_primitive.put(GLenum.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(GLhandleARB.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(GLintptr.class, PrimitiveType.Kind.LONG); + native_types_to_primitive.put(GLsizeiptrARB.class, PrimitiveType.Kind.LONG); + native_types_to_primitive.put(GLubyte.class, PrimitiveType.Kind.BYTE); + native_types_to_primitive.put(GLvoid.class, PrimitiveType.Kind.BYTE); + native_types_to_primitive.put(GLint64EXT.class, PrimitiveType.Kind.LONG); + native_types_to_primitive.put(GLuint64EXT.class, PrimitiveType.Kind.LONG); + native_types_to_primitive.put(GLint64.class, PrimitiveType.Kind.LONG); + native_types_to_primitive.put(GLuint64.class, PrimitiveType.Kind.LONG); + } + + public PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type) { + PrimitiveType.Kind kind = native_types_to_primitive.get(native_type); + if ( kind == null ) + throw new RuntimeException("Unsupported type " + native_type); + return kind; + } + + public void printCapabilitiesInit(final PrintWriter writer) { + writer.println("\t\tContextCapabilities caps = GLContext.getCapabilities();"); + } + + public String getCapabilities() { + return "caps"; + } + + public void printErrorCheckMethod(final PrintWriter writer, final MethodDeclaration method, final String tabs) { + writer.println(tabs + "Util.checkGLError();"); + } + + public String getRegisterNativesFunctionName() { + return "extgl_InitializeClass"; + } + + public Signedness getSignednessFromType(Class type) { + if ( GLuint.class.equals(type) ) + return Signedness.UNSIGNED; + else if ( GLint.class.equals(type) ) + return Signedness.SIGNED; + else if ( GLushort.class.equals(type) ) + return Signedness.UNSIGNED; + else if ( GLshort.class.equals(type) ) + return Signedness.SIGNED; + else if ( GLubyte.class.equals(type) ) + return Signedness.UNSIGNED; + else if ( GLbyte.class.equals(type) ) + return Signedness.SIGNED; + else if ( GLuint64EXT.class.equals(type) ) + return Signedness.UNSIGNED; + else if ( GLint64EXT.class.equals(type) ) + return Signedness.SIGNED; + else if ( GLuint64.class.equals(type) ) + return Signedness.UNSIGNED; + else if ( GLint64.class.equals(type) ) + return Signedness.SIGNED; + else + return Signedness.NONE; + } + + public String translateAnnotation(Class annotation_type) { + if ( annotation_type.equals(GLuint.class) || annotation_type.equals(GLint.class) ) + return "i"; + else if ( annotation_type.equals(GLushort.class) || annotation_type.equals(GLshort.class) ) + return "s"; + else if ( annotation_type.equals(GLubyte.class) || annotation_type.equals(GLbyte.class) ) + return "b"; + else if ( annotation_type.equals(GLfloat.class) || annotation_type.equals(GLclampf.class) ) + return "f"; + else if ( annotation_type.equals(GLdouble.class) || annotation_type.equals(GLclampd.class) ) + return "d"; + else if ( annotation_type.equals(GLhalf.class) ) + return "h"; + else if ( annotation_type.equals(GLuint64EXT.class) || annotation_type.equals(GLint64EXT.class) || annotation_type.equals(GLuint64.class) || annotation_type.equals(GLint64.class) ) + return "i64"; + else if ( annotation_type.equals(GLboolean.class) || annotation_type.equals(GLvoid.class) ) + return ""; + else + throw new RuntimeException(annotation_type + " is not allowed"); + } + + public Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind) { + Class type; + switch ( kind ) { + case INT: + type = GLint.class; + break; + case DOUBLE: + type = GLdouble.class; + break; + case FLOAT: + type = GLfloat.class; + break; + case SHORT: + type = GLshort.class; + break; + case BYTE: + type = GLbyte.class; + break; + case LONG: + type = GLint64EXT.class; + break; + case BOOLEAN: + type = GLboolean.class; + break; + default: + throw new RuntimeException(kind + " is not allowed"); + } + return type; + } + + public Class getVoidType() { + return GLvoid.class; + } + + public Class getStringElementType() { + return GLubyte.class; + } + + public Class getStringArrayType() { + return GLchar.class; + } + + public Class getByteBufferArrayType() { + return GLchar.class; + } + + private static Class[] getValidBufferTypes(Class type) { + if ( type.equals(IntBuffer.class) ) + return new Class[] { GLbitfield.class, GLenum.class, GLhandleARB.class, GLint.class, + GLsizei.class, GLuint.class, GLvoid.class }; + else if ( type.equals(FloatBuffer.class) ) + return new Class[] { GLclampf.class, GLfloat.class }; + else if ( type.equals(ByteBuffer.class) ) + return new Class[] { GLboolean.class, GLbyte.class, GLcharARB.class, GLchar.class, GLubyte.class, GLvoid.class }; + else if ( type.equals(ShortBuffer.class) ) + return new Class[] { GLhalf.class, GLshort.class, GLushort.class }; + else if ( type.equals(DoubleBuffer.class) ) + return new Class[] { GLclampd.class, GLdouble.class }; + else if ( type.equals(LongBuffer.class) ) + return new Class[] { GLint64EXT.class, GLuint64EXT.class, GLint64.class, GLuint64.class }; + else + return new Class[] { }; + } + + private static Class[] getValidPrimitiveTypes(Class type) { + if ( type.equals(long.class) ) + return new Class[] { GLintptrARB.class, GLuint.class, GLintptr.class, GLsizeiptrARB.class, GLsizeiptr.class, GLint64EXT.class, GLuint64EXT.class, GLint64.class, GLuint64.class }; + else if ( type.equals(int.class) ) + return new Class[] { GLbitfield.class, GLenum.class, GLhandleARB.class, GLint.class, GLuint.class, + GLsizei.class }; + else if ( type.equals(double.class) ) + return new Class[] { GLclampd.class, GLdouble.class }; + else if ( type.equals(float.class) ) + return new Class[] { GLclampf.class, GLfloat.class }; + else if ( type.equals(short.class) ) + return new Class[] { GLhalf.class, GLshort.class, GLushort.class }; + else if ( type.equals(byte.class) ) + return new Class[] { GLbyte.class, GLcharARB.class, GLchar.class, GLubyte.class }; + else if ( type.equals(boolean.class) ) + return new Class[] { GLboolean.class }; + else if ( type.equals(void.class) ) + return new Class[] { GLvoid.class, GLreturn.class }; + else + return new Class[] { }; + } + + public String getTypedefPostfix() { + return ""; + } + + public String getFunctionPrefix() { + return "APIENTRY"; + } + + public void printNativeIncludes(PrintWriter writer) { + writer.println("#include \"extgl.h\""); + } + + public Class[] getValidAnnotationTypes(Class type) { + Class[] valid_types; + if ( Buffer.class.isAssignableFrom(type) ) + valid_types = getValidBufferTypes(type); + else if ( type.isPrimitive() ) + valid_types = getValidPrimitiveTypes(type); + else if ( String.class.equals(type) ) + valid_types = new Class[] { GLubyte.class }; + else if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(type) ) + valid_types = new Class[] { PointerWrapper.class }; + else if (void.class.equals(type) ) + valid_types = new Class[] { GLreturn.class }; + else + valid_types = new Class[] { }; + return valid_types; + } + + public Class getInverseType(Class type) { + if ( GLuint.class.equals(type) ) + return GLint.class; + else if ( GLint.class.equals(type) ) + return GLuint.class; + else if ( GLushort.class.equals(type) ) + return GLshort.class; + else if ( GLshort.class.equals(type) ) + return GLushort.class; + else if ( GLubyte.class.equals(type) ) + return GLbyte.class; + else if ( GLbyte.class.equals(type) ) + return GLubyte.class; + else if ( GLuint64EXT.class.equals(type) ) + return GLint64EXT.class; + else if ( GLint64EXT.class.equals(type) ) + return GLuint64EXT.class; + else if ( GLuint64.class.equals(type) ) + return GLint64.class; + else if ( GLint64.class.equals(type) ) + return GLuint64.class; + else + return null; + } + + public String getAutoTypeFromAnnotation(AnnotationMirror annotation) { + Class annotation_class = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType()); + if ( annotation_class.equals(GLint.class) ) + return "GL11.GL_INT"; + else if ( annotation_class.equals(GLbyte.class) ) + return "GL11.GL_BYTE"; + else if ( annotation_class.equals(GLshort.class) ) + return "GL11.GL_SHORT"; + if ( annotation_class.equals(GLuint.class) ) + return "GL11.GL_UNSIGNED_INT"; + else if ( annotation_class.equals(GLubyte.class) ) + return "GL11.GL_UNSIGNED_BYTE"; + else if ( annotation_class.equals(GLushort.class) ) + return "GL11.GL_UNSIGNED_SHORT"; + else if ( annotation_class.equals(GLfloat.class) ) + return "GL11.GL_FLOAT"; + else if ( annotation_class.equals(GLdouble.class) ) + return "GL11.GL_DOUBLE"; + else + return null; + } +} diff --git a/src/java/org/lwjgl/util/generator/GLbitfield.java b/src/java/org/lwjgl/util/generator/opengl/GLbitfield.java similarity index 89% rename from src/java/org/lwjgl/util/generator/GLbitfield.java rename to src/java/org/lwjgl/util/generator/opengl/GLbitfield.java index 9c49c558..6652f88f 100644 --- a/src/java/org/lwjgl/util/generator/GLbitfield.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLbitfield.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLbitfield { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLbitfield.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLbitfield { +} diff --git a/src/java/org/lwjgl/util/generator/GLboolean.java b/src/java/org/lwjgl/util/generator/opengl/GLboolean.java similarity index 89% rename from src/java/org/lwjgl/util/generator/GLboolean.java rename to src/java/org/lwjgl/util/generator/opengl/GLboolean.java index bdacd842..f392283e 100644 --- a/src/java/org/lwjgl/util/generator/GLboolean.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLboolean.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLboolean { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLboolean.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLboolean { +} diff --git a/src/java/org/lwjgl/util/generator/GLbyte.java b/src/java/org/lwjgl/util/generator/opengl/GLbyte.java similarity index 89% rename from src/java/org/lwjgl/util/generator/GLbyte.java rename to src/java/org/lwjgl/util/generator/opengl/GLbyte.java index 82e8bd83..6f4fcc51 100644 --- a/src/java/org/lwjgl/util/generator/GLbyte.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLbyte.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLbyte { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLbyte.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLbyte { +} diff --git a/src/java/org/lwjgl/util/generator/GLchar.java b/src/java/org/lwjgl/util/generator/opengl/GLchar.java similarity index 89% rename from src/java/org/lwjgl/util/generator/GLchar.java rename to src/java/org/lwjgl/util/generator/opengl/GLchar.java index a5603ca3..a31bf425 100644 --- a/src/java/org/lwjgl/util/generator/GLchar.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLchar.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLchar { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLchar.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLchar { +} diff --git a/src/java/org/lwjgl/util/generator/GLcharARB.java b/src/java/org/lwjgl/util/generator/opengl/GLcharARB.java similarity index 89% rename from src/java/org/lwjgl/util/generator/GLcharARB.java rename to src/java/org/lwjgl/util/generator/opengl/GLcharARB.java index a983f6da..25fe1f71 100644 --- a/src/java/org/lwjgl/util/generator/GLcharARB.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLcharARB.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLcharARB { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLcharARB.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLcharARB { +} diff --git a/src/java/org/lwjgl/util/generator/GLclampd.java b/src/java/org/lwjgl/util/generator/opengl/GLclampd.java similarity index 89% rename from src/java/org/lwjgl/util/generator/GLclampd.java rename to src/java/org/lwjgl/util/generator/opengl/GLclampd.java index 90361bd7..21c85fbb 100644 --- a/src/java/org/lwjgl/util/generator/GLclampd.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLclampd.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLclampd { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLclampd.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLclampd { +} diff --git a/src/java/org/lwjgl/util/generator/GLclampf.java b/src/java/org/lwjgl/util/generator/opengl/GLclampf.java similarity index 89% rename from src/java/org/lwjgl/util/generator/GLclampf.java rename to src/java/org/lwjgl/util/generator/opengl/GLclampf.java index 237bc37c..0027efbc 100644 --- a/src/java/org/lwjgl/util/generator/GLclampf.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLclampf.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLclampf { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLclampf.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLclampf { +} diff --git a/src/java/org/lwjgl/util/generator/GLdouble.java b/src/java/org/lwjgl/util/generator/opengl/GLdouble.java similarity index 89% rename from src/java/org/lwjgl/util/generator/GLdouble.java rename to src/java/org/lwjgl/util/generator/opengl/GLdouble.java index 445c5dbb..10fdf389 100644 --- a/src/java/org/lwjgl/util/generator/GLdouble.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLdouble.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLdouble { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLdouble.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLdouble { +} diff --git a/src/java/org/lwjgl/util/generator/GLenum.java b/src/java/org/lwjgl/util/generator/opengl/GLenum.java similarity index 89% rename from src/java/org/lwjgl/util/generator/GLenum.java rename to src/java/org/lwjgl/util/generator/opengl/GLenum.java index 7eef9d80..fecf2eb2 100644 --- a/src/java/org/lwjgl/util/generator/GLenum.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLenum.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLenum { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLenum.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLenum { +} diff --git a/src/java/org/lwjgl/util/generator/GLfloat.java b/src/java/org/lwjgl/util/generator/opengl/GLfloat.java similarity index 89% rename from src/java/org/lwjgl/util/generator/GLfloat.java rename to src/java/org/lwjgl/util/generator/opengl/GLfloat.java index 5d47242e..ba90d6cc 100644 --- a/src/java/org/lwjgl/util/generator/GLfloat.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLfloat.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLfloat { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLfloat.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLfloat { +} diff --git a/src/java/org/lwjgl/util/generator/GLhalf.java b/src/java/org/lwjgl/util/generator/opengl/GLhalf.java similarity index 89% rename from src/java/org/lwjgl/util/generator/GLhalf.java rename to src/java/org/lwjgl/util/generator/opengl/GLhalf.java index 0039848b..dd77e6f0 100644 --- a/src/java/org/lwjgl/util/generator/GLhalf.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLhalf.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLhalf { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLhalf.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLhalf { +} diff --git a/src/java/org/lwjgl/util/generator/GLhandleARB.java b/src/java/org/lwjgl/util/generator/opengl/GLhandleARB.java similarity index 88% rename from src/java/org/lwjgl/util/generator/GLhandleARB.java rename to src/java/org/lwjgl/util/generator/opengl/GLhandleARB.java index 3b6bf2ad..6d8f05e9 100644 --- a/src/java/org/lwjgl/util/generator/GLhandleARB.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLhandleARB.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLhandleARB { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLhandleARB.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLhandleARB { +} diff --git a/src/java/org/lwjgl/util/generator/GLint.java b/src/java/org/lwjgl/util/generator/opengl/GLint.java similarity index 89% rename from src/java/org/lwjgl/util/generator/GLint.java rename to src/java/org/lwjgl/util/generator/opengl/GLint.java index 1cb8e687..cb9fc0db 100644 --- a/src/java/org/lwjgl/util/generator/GLint.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLint.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLint { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLint.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLint { +} diff --git a/src/java/org/lwjgl/util/generator/GLint64.java b/src/java/org/lwjgl/util/generator/opengl/GLint64.java similarity index 93% rename from src/java/org/lwjgl/util/generator/GLint64.java rename to src/java/org/lwjgl/util/generator/opengl/GLint64.java index 75fc705d..e83f0345 100644 --- a/src/java/org/lwjgl/util/generator/GLint64.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLint64.java @@ -29,7 +29,9 @@ * 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.generator; +package org.lwjgl.util.generator.opengl; + +import org.lwjgl.util.generator.NativeType; import java.lang.annotation.Target; import java.lang.annotation.ElementType; diff --git a/src/java/org/lwjgl/util/generator/GLint64EXT.java b/src/java/org/lwjgl/util/generator/opengl/GLint64EXT.java similarity index 93% rename from src/java/org/lwjgl/util/generator/GLint64EXT.java rename to src/java/org/lwjgl/util/generator/opengl/GLint64EXT.java index 7c962128..e2152412 100644 --- a/src/java/org/lwjgl/util/generator/GLint64EXT.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLint64EXT.java @@ -29,7 +29,9 @@ * 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.generator; +package org.lwjgl.util.generator.opengl; + +import org.lwjgl.util.generator.NativeType; import java.lang.annotation.Target; import java.lang.annotation.ElementType; diff --git a/src/java/org/lwjgl/util/generator/GLintptr.java b/src/java/org/lwjgl/util/generator/opengl/GLintptr.java similarity index 89% rename from src/java/org/lwjgl/util/generator/GLintptr.java rename to src/java/org/lwjgl/util/generator/opengl/GLintptr.java index e29436ef..36155ac1 100644 --- a/src/java/org/lwjgl/util/generator/GLintptr.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLintptr.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLintptr { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLintptr.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLintptr { +} diff --git a/src/java/org/lwjgl/util/generator/GLintptrARB.java b/src/java/org/lwjgl/util/generator/opengl/GLintptrARB.java similarity index 88% rename from src/java/org/lwjgl/util/generator/GLintptrARB.java rename to src/java/org/lwjgl/util/generator/opengl/GLintptrARB.java index 20c92a43..5a2e6061 100644 --- a/src/java/org/lwjgl/util/generator/GLintptrARB.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLintptrARB.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLintptrARB { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLintptrARB.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLintptrARB { +} diff --git a/src/java/org/lwjgl/util/generator/GLreturn.java b/src/java/org/lwjgl/util/generator/opengl/GLreturn.java similarity index 94% rename from src/java/org/lwjgl/util/generator/GLreturn.java rename to src/java/org/lwjgl/util/generator/opengl/GLreturn.java index 51fd9e8c..2ab196eb 100644 --- a/src/java/org/lwjgl/util/generator/GLreturn.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLreturn.java @@ -29,7 +29,7 @@ * 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.generator; +package org.lwjgl.util.generator.opengl; /** * When a method is annonated with @GLreturn, the specified output Buffer parameter @@ -38,6 +38,8 @@ package org.lwjgl.util.generator; * * @author spasi */ +import org.lwjgl.util.generator.NativeType; + import java.lang.annotation.ElementType; import java.lang.annotation.Target; diff --git a/src/java/org/lwjgl/util/generator/GLshort.java b/src/java/org/lwjgl/util/generator/opengl/GLshort.java similarity index 89% rename from src/java/org/lwjgl/util/generator/GLshort.java rename to src/java/org/lwjgl/util/generator/opengl/GLshort.java index 3356c3aa..44c27b12 100644 --- a/src/java/org/lwjgl/util/generator/GLshort.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLshort.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLshort { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLshort.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLshort { +} diff --git a/src/java/org/lwjgl/util/generator/GLsizei.java b/src/java/org/lwjgl/util/generator/opengl/GLsizei.java similarity index 89% rename from src/java/org/lwjgl/util/generator/GLsizei.java rename to src/java/org/lwjgl/util/generator/opengl/GLsizei.java index 2597ce3f..ce787e52 100644 --- a/src/java/org/lwjgl/util/generator/GLsizei.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLsizei.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLsizei { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLsizei.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLsizei { +} diff --git a/src/java/org/lwjgl/util/generator/GLsizeiptr.java b/src/java/org/lwjgl/util/generator/opengl/GLsizeiptr.java similarity index 89% rename from src/java/org/lwjgl/util/generator/GLsizeiptr.java rename to src/java/org/lwjgl/util/generator/opengl/GLsizeiptr.java index 6f7808b4..bd9353e1 100644 --- a/src/java/org/lwjgl/util/generator/GLsizeiptr.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLsizeiptr.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLsizeiptr { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLsizeiptr.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLsizeiptr { +} diff --git a/src/java/org/lwjgl/util/generator/GLsizeiptrARB.java b/src/java/org/lwjgl/util/generator/opengl/GLsizeiptrARB.java similarity index 88% rename from src/java/org/lwjgl/util/generator/GLsizeiptrARB.java rename to src/java/org/lwjgl/util/generator/opengl/GLsizeiptrARB.java index d70e4c47..cca0cdb2 100644 --- a/src/java/org/lwjgl/util/generator/GLsizeiptrARB.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLsizeiptrARB.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLsizeiptrARB { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLsizeiptrARB.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLsizeiptrARB { +} diff --git a/src/java/org/lwjgl/util/generator/GLtime.java b/src/java/org/lwjgl/util/generator/opengl/GLtime.java similarity index 93% rename from src/java/org/lwjgl/util/generator/GLtime.java rename to src/java/org/lwjgl/util/generator/opengl/GLtime.java index 81506f1d..c53b62cc 100644 --- a/src/java/org/lwjgl/util/generator/GLtime.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLtime.java @@ -29,7 +29,7 @@ * 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.generator; +package org.lwjgl.util.generator.opengl; /** * Unsigned binary representing an absolute absolute or relative time interval. @@ -38,6 +38,8 @@ package org.lwjgl.util.generator; * @author spasi */ +import org.lwjgl.util.generator.NativeType; + import java.lang.annotation.ElementType; import java.lang.annotation.Target; diff --git a/src/java/org/lwjgl/util/generator/GLubyte.java b/src/java/org/lwjgl/util/generator/opengl/GLubyte.java similarity index 89% rename from src/java/org/lwjgl/util/generator/GLubyte.java rename to src/java/org/lwjgl/util/generator/opengl/GLubyte.java index a9cf0fcf..a22c539b 100644 --- a/src/java/org/lwjgl/util/generator/GLubyte.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLubyte.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLubyte { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLubyte.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLubyte { +} diff --git a/src/java/org/lwjgl/util/generator/GLuint.java b/src/java/org/lwjgl/util/generator/opengl/GLuint.java similarity index 89% rename from src/java/org/lwjgl/util/generator/GLuint.java rename to src/java/org/lwjgl/util/generator/opengl/GLuint.java index dc07f782..44760a85 100644 --- a/src/java/org/lwjgl/util/generator/GLuint.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLuint.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLuint { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLuint.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLuint { +} diff --git a/src/java/org/lwjgl/util/generator/GLuint64.java b/src/java/org/lwjgl/util/generator/opengl/GLuint64.java similarity index 93% rename from src/java/org/lwjgl/util/generator/GLuint64.java rename to src/java/org/lwjgl/util/generator/opengl/GLuint64.java index 0cd089c0..9395dd8b 100644 --- a/src/java/org/lwjgl/util/generator/GLuint64.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLuint64.java @@ -29,7 +29,9 @@ * 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.generator; +package org.lwjgl.util.generator.opengl; + +import org.lwjgl.util.generator.NativeType; import java.lang.annotation.Target; import java.lang.annotation.ElementType; diff --git a/src/java/org/lwjgl/util/generator/GLuint64EXT.java b/src/java/org/lwjgl/util/generator/opengl/GLuint64EXT.java similarity index 93% rename from src/java/org/lwjgl/util/generator/GLuint64EXT.java rename to src/java/org/lwjgl/util/generator/opengl/GLuint64EXT.java index 0eae8e6e..05a228fa 100644 --- a/src/java/org/lwjgl/util/generator/GLuint64EXT.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLuint64EXT.java @@ -29,7 +29,9 @@ * 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.generator; +package org.lwjgl.util.generator.opengl; + +import org.lwjgl.util.generator.NativeType; import java.lang.annotation.Target; import java.lang.annotation.ElementType; diff --git a/src/java/org/lwjgl/util/generator/GLushort.java b/src/java/org/lwjgl/util/generator/opengl/GLushort.java similarity index 89% rename from src/java/org/lwjgl/util/generator/GLushort.java rename to src/java/org/lwjgl/util/generator/opengl/GLushort.java index 538a3f26..18d3198b 100644 --- a/src/java/org/lwjgl/util/generator/GLushort.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLushort.java @@ -1,47 +1,49 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLushort { -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLushort.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLushort { +} diff --git a/src/java/org/lwjgl/util/generator/GLvoid.java b/src/java/org/lwjgl/util/generator/opengl/GLvoid.java similarity index 86% rename from src/java/org/lwjgl/util/generator/GLvoid.java rename to src/java/org/lwjgl/util/generator/opengl/GLvoid.java index cb4f5dba..8cff6a29 100644 --- a/src/java/org/lwjgl/util/generator/GLvoid.java +++ b/src/java/org/lwjgl/util/generator/opengl/GLvoid.java @@ -1,50 +1,52 @@ -/* - * 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 - * 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.generator; - -/** - * - * @author elias_naur - * @version $Revision$ - * $Id$ - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -import com.sun.mirror.type.PrimitiveType; - -@NativeType -@Target({ElementType.PARAMETER, ElementType.METHOD}) -public @interface GLvoid { - PrimitiveType.Kind value() default PrimitiveType.Kind.BYTE; -} +/* + * 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 + * 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.generator.opengl; + +/** + * + * @author elias_naur + * @version $Revision: 3279 $ + * $Id: GLvoid.java 3279 2010-03-11 21:06:49Z spasi $ + */ + +import org.lwjgl.util.generator.NativeType; + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +import com.sun.mirror.type.PrimitiveType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLvoid { + PrimitiveType.Kind value() default PrimitiveType.Kind.BYTE; +} diff --git a/src/native/common/CL/cl.h b/src/native/common/CL/cl.h new file mode 100644 index 00000000..4f21afe5 --- /dev/null +++ b/src/native/common/CL/cl.h @@ -0,0 +1,998 @@ +/******************************************************************************* + * Copyright (c) 2008-2010 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and/or associated documentation files (the + * "Materials"), to deal in the Materials without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Materials, and to + * permit persons to whom the Materials are furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + ******************************************************************************/ + +/* $Revision: 11985 $ on $Date: 2010-07-15 11:16:06 -0700 (Thu, 15 Jul 2010) $ */ + +#ifndef __OPENCL_CL_H +#define __OPENCL_CL_H + +#ifdef __APPLE__ +#include +#else +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/******************************************************************************/ + +typedef struct _cl_platform_id * cl_platform_id; +typedef struct _cl_device_id * cl_device_id; +typedef struct _cl_context * cl_context; +typedef struct _cl_command_queue * cl_command_queue; +typedef struct _cl_mem * cl_mem; +typedef struct _cl_program * cl_program; +typedef struct _cl_kernel * cl_kernel; +typedef struct _cl_event * cl_event; +typedef struct _cl_sampler * cl_sampler; + +typedef cl_uint cl_bool; /* WARNING! Unlike cl_ types in cl_platform.h, cl_bool is not guaranteed to be the same size as the bool in kernels. */ +typedef cl_ulong cl_bitfield; +typedef cl_bitfield cl_device_type; +typedef cl_uint cl_platform_info; +typedef cl_uint cl_device_info; +typedef cl_bitfield cl_device_fp_config; +typedef cl_uint cl_device_mem_cache_type; +typedef cl_uint cl_device_local_mem_type; +typedef cl_bitfield cl_device_exec_capabilities; +typedef cl_bitfield cl_command_queue_properties; + +typedef intptr_t cl_context_properties; +typedef cl_uint cl_context_info; +typedef cl_uint cl_command_queue_info; +typedef cl_uint cl_channel_order; +typedef cl_uint cl_channel_type; +typedef cl_bitfield cl_mem_flags; +typedef cl_uint cl_mem_object_type; +typedef cl_uint cl_mem_info; +typedef cl_uint cl_image_info; +typedef cl_uint cl_buffer_create_type; +typedef cl_uint cl_addressing_mode; +typedef cl_uint cl_filter_mode; +typedef cl_uint cl_sampler_info; +typedef cl_bitfield cl_map_flags; +typedef cl_uint cl_program_info; +typedef cl_uint cl_program_build_info; +typedef cl_int cl_build_status; +typedef cl_uint cl_kernel_info; +typedef cl_uint cl_kernel_work_group_info; +typedef cl_uint cl_event_info; +typedef cl_uint cl_command_type; +typedef cl_uint cl_profiling_info; + +typedef struct _cl_image_format { + cl_channel_order image_channel_order; + cl_channel_type image_channel_data_type; +} cl_image_format; + + +typedef struct _cl_buffer_region { + size_t origin; + size_t size; +} cl_buffer_region; + +/******************************************************************************/ + +/* Error Codes */ +#define CL_SUCCESS 0 +#define CL_DEVICE_NOT_FOUND -1 +#define CL_DEVICE_NOT_AVAILABLE -2 +#define CL_COMPILER_NOT_AVAILABLE -3 +#define CL_MEM_OBJECT_ALLOCATION_FAILURE -4 +#define CL_OUT_OF_RESOURCES -5 +#define CL_OUT_OF_HOST_MEMORY -6 +#define CL_PROFILING_INFO_NOT_AVAILABLE -7 +#define CL_MEM_COPY_OVERLAP -8 +#define CL_IMAGE_FORMAT_MISMATCH -9 +#define CL_IMAGE_FORMAT_NOT_SUPPORTED -10 +#define CL_BUILD_PROGRAM_FAILURE -11 +#define CL_MAP_FAILURE -12 +#define CL_MISALIGNED_SUB_BUFFER_OFFSET -13 +#define CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST -14 + +#define CL_INVALID_VALUE -30 +#define CL_INVALID_DEVICE_TYPE -31 +#define CL_INVALID_PLATFORM -32 +#define CL_INVALID_DEVICE -33 +#define CL_INVALID_CONTEXT -34 +#define CL_INVALID_QUEUE_PROPERTIES -35 +#define CL_INVALID_COMMAND_QUEUE -36 +#define CL_INVALID_HOST_PTR -37 +#define CL_INVALID_MEM_OBJECT -38 +#define CL_INVALID_IMAGE_FORMAT_DESCRIPTOR -39 +#define CL_INVALID_IMAGE_SIZE -40 +#define CL_INVALID_SAMPLER -41 +#define CL_INVALID_BINARY -42 +#define CL_INVALID_BUILD_OPTIONS -43 +#define CL_INVALID_PROGRAM -44 +#define CL_INVALID_PROGRAM_EXECUTABLE -45 +#define CL_INVALID_KERNEL_NAME -46 +#define CL_INVALID_KERNEL_DEFINITION -47 +#define CL_INVALID_KERNEL -48 +#define CL_INVALID_ARG_INDEX -49 +#define CL_INVALID_ARG_VALUE -50 +#define CL_INVALID_ARG_SIZE -51 +#define CL_INVALID_KERNEL_ARGS -52 +#define CL_INVALID_WORK_DIMENSION -53 +#define CL_INVALID_WORK_GROUP_SIZE -54 +#define CL_INVALID_WORK_ITEM_SIZE -55 +#define CL_INVALID_GLOBAL_OFFSET -56 +#define CL_INVALID_EVENT_WAIT_LIST -57 +#define CL_INVALID_EVENT -58 +#define CL_INVALID_OPERATION -59 +#define CL_INVALID_GL_OBJECT -60 +#define CL_INVALID_BUFFER_SIZE -61 +#define CL_INVALID_MIP_LEVEL -62 +#define CL_INVALID_GLOBAL_WORK_SIZE -63 +#define CL_INVALID_PROPERTY -64 + +/* OpenCL Version */ +#define CL_VERSION_1_0 1 +#define CL_VERSION_1_1 1 + +/* cl_bool */ +#define CL_FALSE 0 +#define CL_TRUE 1 + +/* cl_platform_info */ +#define CL_PLATFORM_PROFILE 0x0900 +#define CL_PLATFORM_VERSION 0x0901 +#define CL_PLATFORM_NAME 0x0902 +#define CL_PLATFORM_VENDOR 0x0903 +#define CL_PLATFORM_EXTENSIONS 0x0904 + +/* cl_device_type - bitfield */ +#define CL_DEVICE_TYPE_DEFAULT (1 << 0) +#define CL_DEVICE_TYPE_CPU (1 << 1) +#define CL_DEVICE_TYPE_GPU (1 << 2) +#define CL_DEVICE_TYPE_ACCELERATOR (1 << 3) +#define CL_DEVICE_TYPE_ALL 0xFFFFFFFF + +/* cl_device_info */ +#define CL_DEVICE_TYPE 0x1000 +#define CL_DEVICE_VENDOR_ID 0x1001 +#define CL_DEVICE_MAX_COMPUTE_UNITS 0x1002 +#define CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS 0x1003 +#define CL_DEVICE_MAX_WORK_GROUP_SIZE 0x1004 +#define CL_DEVICE_MAX_WORK_ITEM_SIZES 0x1005 +#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR 0x1006 +#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT 0x1007 +#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT 0x1008 +#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG 0x1009 +#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT 0x100A +#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE 0x100B +#define CL_DEVICE_MAX_CLOCK_FREQUENCY 0x100C +#define CL_DEVICE_ADDRESS_BITS 0x100D +#define CL_DEVICE_MAX_READ_IMAGE_ARGS 0x100E +#define CL_DEVICE_MAX_WRITE_IMAGE_ARGS 0x100F +#define CL_DEVICE_MAX_MEM_ALLOC_SIZE 0x1010 +#define CL_DEVICE_IMAGE2D_MAX_WIDTH 0x1011 +#define CL_DEVICE_IMAGE2D_MAX_HEIGHT 0x1012 +#define CL_DEVICE_IMAGE3D_MAX_WIDTH 0x1013 +#define CL_DEVICE_IMAGE3D_MAX_HEIGHT 0x1014 +#define CL_DEVICE_IMAGE3D_MAX_DEPTH 0x1015 +#define CL_DEVICE_IMAGE_SUPPORT 0x1016 +#define CL_DEVICE_MAX_PARAMETER_SIZE 0x1017 +#define CL_DEVICE_MAX_SAMPLERS 0x1018 +#define CL_DEVICE_MEM_BASE_ADDR_ALIGN 0x1019 +#define CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE 0x101A +#define CL_DEVICE_SINGLE_FP_CONFIG 0x101B +#define CL_DEVICE_GLOBAL_MEM_CACHE_TYPE 0x101C +#define CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE 0x101D +#define CL_DEVICE_GLOBAL_MEM_CACHE_SIZE 0x101E +#define CL_DEVICE_GLOBAL_MEM_SIZE 0x101F +#define CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE 0x1020 +#define CL_DEVICE_MAX_CONSTANT_ARGS 0x1021 +#define CL_DEVICE_LOCAL_MEM_TYPE 0x1022 +#define CL_DEVICE_LOCAL_MEM_SIZE 0x1023 +#define CL_DEVICE_ERROR_CORRECTION_SUPPORT 0x1024 +#define CL_DEVICE_PROFILING_TIMER_RESOLUTION 0x1025 +#define CL_DEVICE_ENDIAN_LITTLE 0x1026 +#define CL_DEVICE_AVAILABLE 0x1027 +#define CL_DEVICE_COMPILER_AVAILABLE 0x1028 +#define CL_DEVICE_EXECUTION_CAPABILITIES 0x1029 +#define CL_DEVICE_QUEUE_PROPERTIES 0x102A +#define CL_DEVICE_NAME 0x102B +#define CL_DEVICE_VENDOR 0x102C +#define CL_DRIVER_VERSION 0x102D +#define CL_DEVICE_PROFILE 0x102E +#define CL_DEVICE_VERSION 0x102F +#define CL_DEVICE_EXTENSIONS 0x1030 +#define CL_DEVICE_PLATFORM 0x1031 +/* 0x1032 reserved for CL_DEVICE_DOUBLE_FP_CONFIG */ +/* 0x1033 reserved for CL_DEVICE_HALF_FP_CONFIG */ +#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF 0x1034 +#define CL_DEVICE_HOST_UNIFIED_MEMORY 0x1035 +#define CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR 0x1036 +#define CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT 0x1037 +#define CL_DEVICE_NATIVE_VECTOR_WIDTH_INT 0x1038 +#define CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG 0x1039 +#define CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT 0x103A +#define CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE 0x103B +#define CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF 0x103C +#define CL_DEVICE_OPENCL_C_VERSION 0x103D + +/* cl_device_fp_config - bitfield */ +#define CL_FP_DENORM (1 << 0) +#define CL_FP_INF_NAN (1 << 1) +#define CL_FP_ROUND_TO_NEAREST (1 << 2) +#define CL_FP_ROUND_TO_ZERO (1 << 3) +#define CL_FP_ROUND_TO_INF (1 << 4) +#define CL_FP_FMA (1 << 5) +#define CL_FP_SOFT_FLOAT (1 << 6) + +/* cl_device_mem_cache_type */ +#define CL_NONE 0x0 +#define CL_READ_ONLY_CACHE 0x1 +#define CL_READ_WRITE_CACHE 0x2 + +/* cl_device_local_mem_type */ +#define CL_LOCAL 0x1 +#define CL_GLOBAL 0x2 + +/* cl_device_exec_capabilities - bitfield */ +#define CL_EXEC_KERNEL (1 << 0) +#define CL_EXEC_NATIVE_KERNEL (1 << 1) + +/* cl_command_queue_properties - bitfield */ +#define CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE (1 << 0) +#define CL_QUEUE_PROFILING_ENABLE (1 << 1) + +/* cl_context_info */ +#define CL_CONTEXT_REFERENCE_COUNT 0x1080 +#define CL_CONTEXT_DEVICES 0x1081 +#define CL_CONTEXT_PROPERTIES 0x1082 +#define CL_CONTEXT_NUM_DEVICES 0x1083 + +/* cl_context_info + cl_context_properties */ +#define CL_CONTEXT_PLATFORM 0x1084 + +/* cl_command_queue_info */ +#define CL_QUEUE_CONTEXT 0x1090 +#define CL_QUEUE_DEVICE 0x1091 +#define CL_QUEUE_REFERENCE_COUNT 0x1092 +#define CL_QUEUE_PROPERTIES 0x1093 + +/* cl_mem_flags - bitfield */ +#define CL_MEM_READ_WRITE (1 << 0) +#define CL_MEM_WRITE_ONLY (1 << 1) +#define CL_MEM_READ_ONLY (1 << 2) +#define CL_MEM_USE_HOST_PTR (1 << 3) +#define CL_MEM_ALLOC_HOST_PTR (1 << 4) +#define CL_MEM_COPY_HOST_PTR (1 << 5) + +/* cl_channel_order */ +#define CL_R 0x10B0 +#define CL_A 0x10B1 +#define CL_RG 0x10B2 +#define CL_RA 0x10B3 +#define CL_RGB 0x10B4 +#define CL_RGBA 0x10B5 +#define CL_BGRA 0x10B6 +#define CL_ARGB 0x10B7 +#define CL_INTENSITY 0x10B8 +#define CL_LUMINANCE 0x10B9 +#define CL_Rx 0x10BA +#define CL_RGx 0x10BB +#define CL_RGBx 0x10BC + +/* cl_channel_type */ +#define CL_SNORM_INT8 0x10D0 +#define CL_SNORM_INT16 0x10D1 +#define CL_UNORM_INT8 0x10D2 +#define CL_UNORM_INT16 0x10D3 +#define CL_UNORM_SHORT_565 0x10D4 +#define CL_UNORM_SHORT_555 0x10D5 +#define CL_UNORM_INT_101010 0x10D6 +#define CL_SIGNED_INT8 0x10D7 +#define CL_SIGNED_INT16 0x10D8 +#define CL_SIGNED_INT32 0x10D9 +#define CL_UNSIGNED_INT8 0x10DA +#define CL_UNSIGNED_INT16 0x10DB +#define CL_UNSIGNED_INT32 0x10DC +#define CL_HALF_FLOAT 0x10DD +#define CL_FLOAT 0x10DE + +/* cl_mem_object_type */ +#define CL_MEM_OBJECT_BUFFER 0x10F0 +#define CL_MEM_OBJECT_IMAGE2D 0x10F1 +#define CL_MEM_OBJECT_IMAGE3D 0x10F2 + +/* cl_mem_info */ +#define CL_MEM_TYPE 0x1100 +#define CL_MEM_FLAGS 0x1101 +#define CL_MEM_SIZE 0x1102 +#define CL_MEM_HOST_PTR 0x1103 +#define CL_MEM_MAP_COUNT 0x1104 +#define CL_MEM_REFERENCE_COUNT 0x1105 +#define CL_MEM_CONTEXT 0x1106 +#define CL_MEM_ASSOCIATED_MEMOBJECT 0x1107 +#define CL_MEM_OFFSET 0x1108 + +/* cl_image_info */ +#define CL_IMAGE_FORMAT 0x1110 +#define CL_IMAGE_ELEMENT_SIZE 0x1111 +#define CL_IMAGE_ROW_PITCH 0x1112 +#define CL_IMAGE_SLICE_PITCH 0x1113 +#define CL_IMAGE_WIDTH 0x1114 +#define CL_IMAGE_HEIGHT 0x1115 +#define CL_IMAGE_DEPTH 0x1116 + +/* cl_addressing_mode */ +#define CL_ADDRESS_NONE 0x1130 +#define CL_ADDRESS_CLAMP_TO_EDGE 0x1131 +#define CL_ADDRESS_CLAMP 0x1132 +#define CL_ADDRESS_REPEAT 0x1133 +#define CL_ADDRESS_MIRRORED_REPEAT 0x1134 + +/* cl_filter_mode */ +#define CL_FILTER_NEAREST 0x1140 +#define CL_FILTER_LINEAR 0x1141 + +/* cl_sampler_info */ +#define CL_SAMPLER_REFERENCE_COUNT 0x1150 +#define CL_SAMPLER_CONTEXT 0x1151 +#define CL_SAMPLER_NORMALIZED_COORDS 0x1152 +#define CL_SAMPLER_ADDRESSING_MODE 0x1153 +#define CL_SAMPLER_FILTER_MODE 0x1154 + +/* cl_map_flags - bitfield */ +#define CL_MAP_READ (1 << 0) +#define CL_MAP_WRITE (1 << 1) + +/* cl_program_info */ +#define CL_PROGRAM_REFERENCE_COUNT 0x1160 +#define CL_PROGRAM_CONTEXT 0x1161 +#define CL_PROGRAM_NUM_DEVICES 0x1162 +#define CL_PROGRAM_DEVICES 0x1163 +#define CL_PROGRAM_SOURCE 0x1164 +#define CL_PROGRAM_BINARY_SIZES 0x1165 +#define CL_PROGRAM_BINARIES 0x1166 + +/* cl_program_build_info */ +#define CL_PROGRAM_BUILD_STATUS 0x1181 +#define CL_PROGRAM_BUILD_OPTIONS 0x1182 +#define CL_PROGRAM_BUILD_LOG 0x1183 + +/* cl_build_status */ +#define CL_BUILD_SUCCESS 0 +#define CL_BUILD_NONE -1 +#define CL_BUILD_ERROR -2 +#define CL_BUILD_IN_PROGRESS -3 + +/* cl_kernel_info */ +#define CL_KERNEL_FUNCTION_NAME 0x1190 +#define CL_KERNEL_NUM_ARGS 0x1191 +#define CL_KERNEL_REFERENCE_COUNT 0x1192 +#define CL_KERNEL_CONTEXT 0x1193 +#define CL_KERNEL_PROGRAM 0x1194 + +/* cl_kernel_work_group_info */ +#define CL_KERNEL_WORK_GROUP_SIZE 0x11B0 +#define CL_KERNEL_COMPILE_WORK_GROUP_SIZE 0x11B1 +#define CL_KERNEL_LOCAL_MEM_SIZE 0x11B2 +#define CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE 0x11B3 +#define CL_KERNEL_PRIVATE_MEM_SIZE 0x11B4 + +/* cl_event_info */ +#define CL_EVENT_COMMAND_QUEUE 0x11D0 +#define CL_EVENT_COMMAND_TYPE 0x11D1 +#define CL_EVENT_REFERENCE_COUNT 0x11D2 +#define CL_EVENT_COMMAND_EXECUTION_STATUS 0x11D3 +#define CL_EVENT_CONTEXT 0x11D4 + +/* cl_command_type */ +#define CL_COMMAND_NDRANGE_KERNEL 0x11F0 +#define CL_COMMAND_TASK 0x11F1 +#define CL_COMMAND_NATIVE_KERNEL 0x11F2 +#define CL_COMMAND_READ_BUFFER 0x11F3 +#define CL_COMMAND_WRITE_BUFFER 0x11F4 +#define CL_COMMAND_COPY_BUFFER 0x11F5 +#define CL_COMMAND_READ_IMAGE 0x11F6 +#define CL_COMMAND_WRITE_IMAGE 0x11F7 +#define CL_COMMAND_COPY_IMAGE 0x11F8 +#define CL_COMMAND_COPY_IMAGE_TO_BUFFER 0x11F9 +#define CL_COMMAND_COPY_BUFFER_TO_IMAGE 0x11FA +#define CL_COMMAND_MAP_BUFFER 0x11FB +#define CL_COMMAND_MAP_IMAGE 0x11FC +#define CL_COMMAND_UNMAP_MEM_OBJECT 0x11FD +#define CL_COMMAND_MARKER 0x11FE +#define CL_COMMAND_ACQUIRE_GL_OBJECTS 0x11FF +#define CL_COMMAND_RELEASE_GL_OBJECTS 0x1200 +#define CL_COMMAND_READ_BUFFER_RECT 0x1201 +#define CL_COMMAND_WRITE_BUFFER_RECT 0x1202 +#define CL_COMMAND_COPY_BUFFER_RECT 0x1203 +#define CL_COMMAND_USER 0x1204 + +/* command execution status */ +#define CL_COMPLETE 0x0 +#define CL_RUNNING 0x1 +#define CL_SUBMITTED 0x2 +#define CL_QUEUED 0x3 + +/* cl_buffer_create_type */ +#define CL_BUFFER_CREATE_TYPE_REGION 0x1220 + +/* cl_profiling_info */ +#define CL_PROFILING_COMMAND_QUEUED 0x1280 +#define CL_PROFILING_COMMAND_SUBMIT 0x1281 +#define CL_PROFILING_COMMAND_START 0x1282 +#define CL_PROFILING_COMMAND_END 0x1283 + +/********************************************************************************************************/ + +/* Platform API */ +extern CL_API_ENTRY cl_int CL_API_CALL +clGetPlatformIDs(cl_uint /* num_entries */, + cl_platform_id * /* platforms */, + cl_uint * /* num_platforms */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetPlatformInfo(cl_platform_id /* platform */, + cl_platform_info /* param_name */, + size_t /* param_value_size */, + void * /* param_value */, + size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; + +/* Device APIs */ +extern CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceIDs(cl_platform_id /* platform */, + cl_device_type /* device_type */, + cl_uint /* num_entries */, + cl_device_id * /* devices */, + cl_uint * /* num_devices */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceInfo(cl_device_id /* device */, + cl_device_info /* param_name */, + size_t /* param_value_size */, + void * /* param_value */, + size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; + +/* Context APIs */ +extern CL_API_ENTRY cl_context CL_API_CALL +clCreateContext(const cl_context_properties * /* properties */, + cl_uint /* num_devices */, + const cl_device_id * /* devices */, + void (CL_CALLBACK * /* pfn_notify */)(const char *, const void *, size_t, void *), + void * /* user_data */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_context CL_API_CALL +clCreateContextFromType(const cl_context_properties * /* properties */, + cl_device_type /* device_type */, + void (CL_CALLBACK * /* pfn_notify*/ )(const char *, const void *, size_t, void *), + void * /* user_data */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clRetainContext(cl_context /* context */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clReleaseContext(cl_context /* context */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetContextInfo(cl_context /* context */, + cl_context_info /* param_name */, + size_t /* param_value_size */, + void * /* param_value */, + size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; + +/* Command Queue APIs */ +extern CL_API_ENTRY cl_command_queue CL_API_CALL +clCreateCommandQueue(cl_context /* context */, + cl_device_id /* device */, + cl_command_queue_properties /* properties */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clRetainCommandQueue(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clReleaseCommandQueue(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetCommandQueueInfo(cl_command_queue /* command_queue */, + cl_command_queue_info /* param_name */, + size_t /* param_value_size */, + void * /* param_value */, + size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; + +#ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS +#warning CL_USE_DEPRECATED_OPENCL_1_0_APIS is defined. These APIs are unsupported and untested in OpenCL 1.1! +/* + * WARNING: + * This API introduces mutable state into the OpenCL implementation. It has been REMOVED + * to better facilitate thread safety. The 1.0 API is not thread safe. It is not tested by the + * OpenCL 1.1 conformance test, and consequently may not work or may not work dependably. + * It is likely to be non-performant. Use of this API is not advised. Use at your own risk. + * + * Software developers previously relying on this API are instructed to set the command queue + * properties when creating the queue, instead. + */ +extern CL_API_ENTRY cl_int CL_API_CALL +clSetCommandQueueProperty(cl_command_queue /* command_queue */, + cl_command_queue_properties /* properties */, + cl_bool /* enable */, + cl_command_queue_properties * /* old_properties */) CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED; +#endif /* CL_USE_DEPRECATED_OPENCL_1_0_APIS */ + +/* Memory Object APIs */ +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateBuffer(cl_context /* context */, + cl_mem_flags /* flags */, + size_t /* size */, + void * /* host_ptr */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateSubBuffer(cl_mem /* buffer */, + cl_mem_flags /* flags */, + cl_buffer_create_type /* buffer_create_type */, + const void * /* buffer_create_info */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1; + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateImage2D(cl_context /* context */, + cl_mem_flags /* flags */, + const cl_image_format * /* image_format */, + size_t /* image_width */, + size_t /* image_height */, + size_t /* image_row_pitch */, + void * /* host_ptr */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateImage3D(cl_context /* context */, + cl_mem_flags /* flags */, + const cl_image_format * /* image_format */, + size_t /* image_width */, + size_t /* image_height */, + size_t /* image_depth */, + size_t /* image_row_pitch */, + size_t /* image_slice_pitch */, + void * /* host_ptr */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clRetainMemObject(cl_mem /* memobj */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clReleaseMemObject(cl_mem /* memobj */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetSupportedImageFormats(cl_context /* context */, + cl_mem_flags /* flags */, + cl_mem_object_type /* image_type */, + cl_uint /* num_entries */, + cl_image_format * /* image_formats */, + cl_uint * /* num_image_formats */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetMemObjectInfo(cl_mem /* memobj */, + cl_mem_info /* param_name */, + size_t /* param_value_size */, + void * /* param_value */, + size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetImageInfo(cl_mem /* image */, + cl_image_info /* param_name */, + size_t /* param_value_size */, + void * /* param_value */, + size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clSetMemObjectDestructorCallback( cl_mem /* memobj */, + void (CL_CALLBACK * /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/), + void * /*user_data */ ) CL_API_SUFFIX__VERSION_1_1; + +/* Sampler APIs */ +extern CL_API_ENTRY cl_sampler CL_API_CALL +clCreateSampler(cl_context /* context */, + cl_bool /* normalized_coords */, + cl_addressing_mode /* addressing_mode */, + cl_filter_mode /* filter_mode */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clRetainSampler(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clReleaseSampler(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetSamplerInfo(cl_sampler /* sampler */, + cl_sampler_info /* param_name */, + size_t /* param_value_size */, + void * /* param_value */, + size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; + +/* Program Object APIs */ +extern CL_API_ENTRY cl_program CL_API_CALL +clCreateProgramWithSource(cl_context /* context */, + cl_uint /* count */, + const char ** /* strings */, + const size_t * /* lengths */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_program CL_API_CALL +clCreateProgramWithBinary(cl_context /* context */, + cl_uint /* num_devices */, + const cl_device_id * /* device_list */, + const size_t * /* lengths */, + const unsigned char ** /* binaries */, + cl_int * /* binary_status */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clRetainProgram(cl_program /* program */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clReleaseProgram(cl_program /* program */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clBuildProgram(cl_program /* program */, + cl_uint /* num_devices */, + const cl_device_id * /* device_list */, + const char * /* options */, + void (CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, void * /* user_data */), + void * /* user_data */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clUnloadCompiler(void) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetProgramInfo(cl_program /* program */, + cl_program_info /* param_name */, + size_t /* param_value_size */, + void * /* param_value */, + size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetProgramBuildInfo(cl_program /* program */, + cl_device_id /* device */, + cl_program_build_info /* param_name */, + size_t /* param_value_size */, + void * /* param_value */, + size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; + +/* Kernel Object APIs */ +extern CL_API_ENTRY cl_kernel CL_API_CALL +clCreateKernel(cl_program /* program */, + const char * /* kernel_name */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clCreateKernelsInProgram(cl_program /* program */, + cl_uint /* num_kernels */, + cl_kernel * /* kernels */, + cl_uint * /* num_kernels_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clRetainKernel(cl_kernel /* kernel */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clReleaseKernel(cl_kernel /* kernel */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clSetKernelArg(cl_kernel /* kernel */, + cl_uint /* arg_index */, + size_t /* arg_size */, + const void * /* arg_value */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetKernelInfo(cl_kernel /* kernel */, + cl_kernel_info /* param_name */, + size_t /* param_value_size */, + void * /* param_value */, + size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetKernelWorkGroupInfo(cl_kernel /* kernel */, + cl_device_id /* device */, + cl_kernel_work_group_info /* param_name */, + size_t /* param_value_size */, + void * /* param_value */, + size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; + +/* Event Object APIs */ +extern CL_API_ENTRY cl_int CL_API_CALL +clWaitForEvents(cl_uint /* num_events */, + const cl_event * /* event_list */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetEventInfo(cl_event /* event */, + cl_event_info /* param_name */, + size_t /* param_value_size */, + void * /* param_value */, + size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_event CL_API_CALL +clCreateUserEvent(cl_context /* context */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1; + +extern CL_API_ENTRY cl_int CL_API_CALL +clRetainEvent(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clReleaseEvent(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clSetUserEventStatus(cl_event /* event */, + cl_int /* execution_status */) CL_API_SUFFIX__VERSION_1_1; + +extern CL_API_ENTRY cl_int CL_API_CALL +clSetEventCallback( cl_event /* event */, + cl_int /* command_exec_callback_type */, + void (CL_CALLBACK * /* pfn_notify */)(cl_event, cl_int, void *), + void * /* user_data */) CL_API_SUFFIX__VERSION_1_1; + +/* Profiling APIs */ +extern CL_API_ENTRY cl_int CL_API_CALL +clGetEventProfilingInfo(cl_event /* event */, + cl_profiling_info /* param_name */, + size_t /* param_value_size */, + void * /* param_value */, + size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; + +/* Flush and Finish APIs */ +extern CL_API_ENTRY cl_int CL_API_CALL +clFlush(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clFinish(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0; + +/* Enqueued Commands APIs */ +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReadBuffer(cl_command_queue /* command_queue */, + cl_mem /* buffer */, + cl_bool /* blocking_read */, + size_t /* offset */, + size_t /* cb */, + void * /* ptr */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReadBufferRect(cl_command_queue /* command_queue */, + cl_mem /* buffer */, + cl_bool /* blocking_read */, + const size_t * /* buffer_origin */, + const size_t * /* host_origin */, + const size_t * /* region */, + size_t /* buffer_row_pitch */, + size_t /* buffer_slice_pitch */, + size_t /* host_row_pitch */, + size_t /* host_slice_pitch */, + void * /* ptr */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueWriteBuffer(cl_command_queue /* command_queue */, + cl_mem /* buffer */, + cl_bool /* blocking_write */, + size_t /* offset */, + size_t /* cb */, + const void * /* ptr */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueWriteBufferRect(cl_command_queue /* command_queue */, + cl_mem /* buffer */, + cl_bool /* blocking_write */, + const size_t * /* buffer_origin */, + const size_t * /* host_origin */, + const size_t * /* region */, + size_t /* buffer_row_pitch */, + size_t /* buffer_slice_pitch */, + size_t /* host_row_pitch */, + size_t /* host_slice_pitch */, + const void * /* ptr */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueCopyBuffer(cl_command_queue /* command_queue */, + cl_mem /* src_buffer */, + cl_mem /* dst_buffer */, + size_t /* src_offset */, + size_t /* dst_offset */, + size_t /* cb */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueCopyBufferRect(cl_command_queue /* command_queue */, + cl_mem /* src_buffer */, + cl_mem /* dst_buffer */, + const size_t * /* src_origin */, + const size_t * /* dst_origin */, + const size_t * /* region */, + size_t /* src_row_pitch */, + size_t /* src_slice_pitch */, + size_t /* dst_row_pitch */, + size_t /* dst_slice_pitch */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReadImage(cl_command_queue /* command_queue */, + cl_mem /* image */, + cl_bool /* blocking_read */, + const size_t * /* origin[3] */, + const size_t * /* region[3] */, + size_t /* row_pitch */, + size_t /* slice_pitch */, + void * /* ptr */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueWriteImage(cl_command_queue /* command_queue */, + cl_mem /* image */, + cl_bool /* blocking_write */, + const size_t * /* origin[3] */, + const size_t * /* region[3] */, + size_t /* input_row_pitch */, + size_t /* input_slice_pitch */, + const void * /* ptr */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueCopyImage(cl_command_queue /* command_queue */, + cl_mem /* src_image */, + cl_mem /* dst_image */, + const size_t * /* src_origin[3] */, + const size_t * /* dst_origin[3] */, + const size_t * /* region[3] */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueCopyImageToBuffer(cl_command_queue /* command_queue */, + cl_mem /* src_image */, + cl_mem /* dst_buffer */, + const size_t * /* src_origin[3] */, + const size_t * /* region[3] */, + size_t /* dst_offset */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueCopyBufferToImage(cl_command_queue /* command_queue */, + cl_mem /* src_buffer */, + cl_mem /* dst_image */, + size_t /* src_offset */, + const size_t * /* dst_origin[3] */, + const size_t * /* region[3] */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY void * CL_API_CALL +clEnqueueMapBuffer(cl_command_queue /* command_queue */, + cl_mem /* buffer */, + cl_bool /* blocking_map */, + cl_map_flags /* map_flags */, + size_t /* offset */, + size_t /* cb */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY void * CL_API_CALL +clEnqueueMapImage(cl_command_queue /* command_queue */, + cl_mem /* image */, + cl_bool /* blocking_map */, + cl_map_flags /* map_flags */, + const size_t * /* origin[3] */, + const size_t * /* region[3] */, + size_t * /* image_row_pitch */, + size_t * /* image_slice_pitch */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueUnmapMemObject(cl_command_queue /* command_queue */, + cl_mem /* memobj */, + void * /* mapped_ptr */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueNDRangeKernel(cl_command_queue /* command_queue */, + cl_kernel /* kernel */, + cl_uint /* work_dim */, + const size_t * /* global_work_offset */, + const size_t * /* global_work_size */, + const size_t * /* local_work_size */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueTask(cl_command_queue /* command_queue */, + cl_kernel /* kernel */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueNativeKernel(cl_command_queue /* command_queue */, + void (*user_func)(void *), + void * /* args */, + size_t /* cb_args */, + cl_uint /* num_mem_objects */, + const cl_mem * /* mem_list */, + const void ** /* args_mem_loc */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueMarker(cl_command_queue /* command_queue */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueWaitForEvents(cl_command_queue /* command_queue */, + cl_uint /* num_events */, + const cl_event * /* event_list */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueBarrier(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0; + +/* Extension function access + * + * Returns the extension function address for the given function name, + * or NULL if a valid function can not be found. The client must + * check to make sure the address is not NULL, before using or + * calling the returned function address. + */ +extern CL_API_ENTRY void * CL_API_CALL clGetExtensionFunctionAddress(const char * /* func_name */) CL_API_SUFFIX__VERSION_1_0; + +#ifdef __cplusplus +} +#endif + +#endif /* __OPENCL_CL_H */ + diff --git a/src/native/common/CL/cl_d3d10.h b/src/native/common/CL/cl_d3d10.h new file mode 100644 index 00000000..ea9ab99c --- /dev/null +++ b/src/native/common/CL/cl_d3d10.h @@ -0,0 +1,126 @@ +/********************************************************************************** + * Copyright (c) 2008-2010 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and/or associated documentation files (the + * "Materials"), to deal in the Materials without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Materials, and to + * permit persons to whom the Materials are furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + **********************************************************************************/ + +/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */ + +#ifndef __OPENCL_CL_D3D10_H +#define __OPENCL_CL_D3D10_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************** + * cl_khr_d3d10_sharing */ +#define cl_khr_d3d10_sharing 1 + +typedef cl_uint cl_d3d10_device_source_khr; +typedef cl_uint cl_d3d10_device_set_khr; + +/******************************************************************************/ + +// Error Codes +#define CL_INVALID_D3D10_DEVICE_KHR -1002 +#define CL_INVALID_D3D10_RESOURCE_KHR -1003 +#define CL_D3D10_RESOURCE_ALREADY_ACQUIRED_KHR -1004 +#define CL_D3D10_RESOURCE_NOT_ACQUIRED_KHR -1005 + +// cl_d3d10_device_source_nv +#define CL_D3D10_DEVICE_KHR 0x4010 +#define CL_D3D10_DXGI_ADAPTER_KHR 0x4011 + +// cl_d3d10_device_set_nv +#define CL_PREFERRED_DEVICES_FOR_D3D10_KHR 0x4012 +#define CL_ALL_DEVICES_FOR_D3D10_KHR 0x4013 + +// cl_context_info +#define CL_CONTEXT_D3D10_DEVICE_KHR 0x4014 +#define CL_CONTEXT_D3D10_PREFER_SHARED_RESOURCES_KHR 0x402C + +// cl_mem_info +#define CL_MEM_D3D10_RESOURCE_KHR 0x4015 + +// cl_image_info +#define CL_IMAGE_D3D10_SUBRESOURCE_KHR 0x4016 + +// cl_command_type +#define CL_COMMAND_ACQUIRE_D3D10_OBJECTS_KHR 0x4017 +#define CL_COMMAND_RELEASE_D3D10_OBJECTS_KHR 0x4018 + +/******************************************************************************/ + +typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDsFromD3D10KHR_fn)( + cl_platform_id platform, + cl_d3d10_device_source_khr d3d_device_source, + void * d3d_object, + cl_d3d10_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id * devices, + cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10BufferKHR_fn)( + cl_context context, + cl_mem_flags flags, + ID3D10Buffer * resource, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10Texture2DKHR_fn)( + cl_context context, + cl_mem_flags flags, + ID3D10Texture2D * resource, + UINT subresource, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10Texture3DKHR_fn)( + cl_context context, + cl_mem_flags flags, + ID3D10Texture3D * resource, + UINT subresource, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireD3D10ObjectsKHR_fn)( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseD3D10ObjectsKHR_fn)( + cl_command_queue command_queue, + cl_uint num_objects, + cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) CL_API_SUFFIX__VERSION_1_0; + +#ifdef __cplusplus +} +#endif + +#endif // __OPENCL_CL_D3D10_H + diff --git a/src/native/common/CL/cl_ext.h b/src/native/common/CL/cl_ext.h new file mode 100644 index 00000000..4e92c7e6 --- /dev/null +++ b/src/native/common/CL/cl_ext.h @@ -0,0 +1,213 @@ +/******************************************************************************* + * Copyright (c) 2008-2010 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and/or associated documentation files (the + * "Materials"), to deal in the Materials without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Materials, and to + * permit persons to whom the Materials are furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + ******************************************************************************/ + +/* $Revision: 11928 $ on $Date: 2010-07-13 09:04:56 -0700 (Tue, 13 Jul 2010) $ */ + +/* cl_ext.h contains OpenCL extensions which don't have external */ +/* (OpenGL, D3D) dependencies. */ + +#ifndef __CL_EXT_H +#define __CL_EXT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __APPLE__ + #include + #include +#else + #include +#endif + +/* cl_khr_fp64 extension - no extension #define since it has no functions */ +#define CL_DEVICE_DOUBLE_FP_CONFIG 0x1032 + +/* cl_khr_fp16 extension - no extension #define since it has no functions */ +#define CL_DEVICE_HALF_FP_CONFIG 0x1033 + +/* Memory object destruction + * + * Apple extension for use to manage externally allocated buffers used with cl_mem objects with CL_MEM_USE_HOST_PTR + * + * Registers a user callback function that will be called when the memory object is deleted and its resources + * freed. Each call to clSetMemObjectCallbackFn registers the specified user callback function on a callback + * stack associated with memobj. The registered user callback functions are called in the reverse order in + * which they were registered. The user callback functions are called and then the memory object is deleted + * and its resources freed. This provides a mechanism for the application (and libraries) using memobj to be + * notified when the memory referenced by host_ptr, specified when the memory object is created and used as + * the storage bits for the memory object, can be reused or freed. + * + * The application may not call CL api's with the cl_mem object passed to the pfn_notify. + * + * Please check for the "cl_APPLE_SetMemObjectDestructor" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS) + * before using. + */ +#define cl_APPLE_SetMemObjectDestructor 1 +cl_int CL_API_ENTRY clSetMemObjectDestructorAPPLE( cl_mem /* memobj */, + void (* /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/), + void * /*user_data */ ) CL_EXT_SUFFIX__VERSION_1_0; + + +/* Context Logging Functions + * + * The next three convenience functions are intended to be used as the pfn_notify parameter to clCreateContext(). + * Please check for the "cl_APPLE_ContextLoggingFunctions" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS) + * before using. + * + * clLogMessagesToSystemLog fowards on all log messages to the Apple System Logger + */ +#define cl_APPLE_ContextLoggingFunctions 1 +extern void CL_API_ENTRY clLogMessagesToSystemLogAPPLE( const char * /* errstr */, + const void * /* private_info */, + size_t /* cb */, + void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0; + +/* clLogMessagesToStdout sends all log messages to the file descriptor stdout */ +extern void CL_API_ENTRY clLogMessagesToStdoutAPPLE( const char * /* errstr */, + const void * /* private_info */, + size_t /* cb */, + void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0; + +/* clLogMessagesToStderr sends all log messages to the file descriptor stderr */ +extern void CL_API_ENTRY clLogMessagesToStderrAPPLE( const char * /* errstr */, + const void * /* private_info */, + size_t /* cb */, + void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0; + + +/************************ +* cl_khr_icd extension * +************************/ +#define cl_khr_icd 1 + +/* cl_platform_info */ +#define CL_PLATFORM_ICD_SUFFIX_KHR 0x0920 + +/* Additional Error Codes */ +#define CL_PLATFORM_NOT_FOUND_KHR -1001 + +extern CL_API_ENTRY cl_int CL_API_CALL +clIcdGetPlatformIDsKHR(cl_uint /* num_entries */, + cl_platform_id * /* platforms */, + cl_uint * /* num_platforms */); + +typedef CL_API_ENTRY cl_int (CL_API_CALL *clIcdGetPlatformIDsKHR_fn)( + cl_uint /* num_entries */, + cl_platform_id * /* platforms */, + cl_uint * /* num_platforms */); + + +/****************************************** +* cl_nv_device_attribute_query extension * +******************************************/ +/* cl_nv_device_attribute_query extension - no extension #define since it has no functions */ +#define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000 +#define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001 +#define CL_DEVICE_REGISTERS_PER_BLOCK_NV 0x4002 +#define CL_DEVICE_WARP_SIZE_NV 0x4003 +#define CL_DEVICE_GPU_OVERLAP_NV 0x4004 +#define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005 +#define CL_DEVICE_INTEGRATED_MEMORY_NV 0x4006 + + +/********************************* +* cl_amd_device_attribute_query * +*********************************/ +#define CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 0x4036 + + +#ifdef CL_VERSION_1_1 + /*********************************** + * cl_ext_device_fission extension * + ***********************************/ + #define cl_ext_device_fission 1 + + extern CL_API_ENTRY cl_int CL_API_CALL + clReleaseDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1; + + typedef CL_API_ENTRY cl_int + (CL_API_CALL *clReleaseDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1; + + extern CL_API_ENTRY cl_int CL_API_CALL + clRetainDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1; + + typedef CL_API_ENTRY cl_int + (CL_API_CALL *clRetainDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1; + + typedef cl_ulong cl_device_partition_property_ext; + extern CL_API_ENTRY cl_int CL_API_CALL + clCreateSubDevicesEXT( cl_device_id /*in_device*/, + const cl_device_partition_property_ext * /* properties */, + cl_uint /*num_entries*/, + cl_device_id * /*out_devices*/, + cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1; + + typedef CL_API_ENTRY cl_int + ( CL_API_CALL * clCreateSubDevicesEXT_fn)( cl_device_id /*in_device*/, + const cl_device_partition_property_ext * /* properties */, + cl_uint /*num_entries*/, + cl_device_id * /*out_devices*/, + cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1; + + /* cl_device_partition_property_ext */ + #define CL_DEVICE_PARTITION_EQUALLY_EXT 0x4050 + #define CL_DEVICE_PARTITION_BY_COUNTS_EXT 0x4051 + #define CL_DEVICE_PARTITION_BY_NAMES_EXT 0x4052 + #define CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT 0x4053 + + /* clDeviceGetInfo selectors */ + #define CL_DEVICE_PARENT_DEVICE_EXT 0x4054 + #define CL_DEVICE_PARTITION_TYPES_EXT 0x4055 + #define CL_DEVICE_AFFINITY_DOMAINS_EXT 0x4056 + #define CL_DEVICE_REFERENCE_COUNT_EXT 0x4057 + #define CL_DEVICE_PARTITION_STYLE_EXT 0x4058 + + /* error codes */ + #define CL_DEVICE_PARTITION_FAILED_EXT -1057 + #define CL_INVALID_PARTITION_COUNT_EXT -1058 + #define CL_INVALID_PARTITION_NAME_EXT -1059 + + /* CL_AFFINITY_DOMAINs */ + #define CL_AFFINITY_DOMAIN_L1_CACHE_EXT 0x1 + #define CL_AFFINITY_DOMAIN_L2_CACHE_EXT 0x2 + #define CL_AFFINITY_DOMAIN_L3_CACHE_EXT 0x3 + #define CL_AFFINITY_DOMAIN_L4_CACHE_EXT 0x4 + #define CL_AFFINITY_DOMAIN_NUMA_EXT 0x10 + #define CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT 0x100 + + /* cl_device_partition_property_ext list terminators */ + #define CL_PROPERTIES_LIST_END_EXT ((cl_device_partition_property_ext) 0) + #define CL_PARTITION_BY_COUNTS_LIST_END_EXT ((cl_device_partition_property_ext) 0) + #define CL_PARTITION_BY_NAMES_LIST_END_EXT ((cl_device_partition_property_ext) 0 - 1) + + + +#endif /* CL_VERSION_1_1 */ + +#ifdef __cplusplus +} +#endif + + +#endif /* __CL_EXT_H */ diff --git a/src/native/common/CL/cl_gl.h b/src/native/common/CL/cl_gl.h new file mode 100644 index 00000000..3b4fe069 --- /dev/null +++ b/src/native/common/CL/cl_gl.h @@ -0,0 +1,155 @@ +/********************************************************************************** + * Copyright (c) 2008-2010 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and/or associated documentation files (the + * "Materials"), to deal in the Materials without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Materials, and to + * permit persons to whom the Materials are furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + **********************************************************************************/ + +/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */ + +/* + * cl_gl.h contains Khronos-approved (KHR) OpenCL extensions which have + * OpenGL dependencies. The application is responsible for #including + * OpenGL or OpenGL ES headers before #including cl_gl.h. + */ + +#ifndef __OPENCL_CL_GL_H +#define __OPENCL_CL_GL_H + +#ifdef __APPLE__ +#include +#include +#else +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef cl_uint cl_gl_object_type; +typedef cl_uint cl_gl_texture_info; +typedef cl_uint cl_gl_platform_info; +typedef struct __GLsync *cl_GLsync; + +/* cl_gl_object_type */ +#define CL_GL_OBJECT_BUFFER 0x2000 +#define CL_GL_OBJECT_TEXTURE2D 0x2001 +#define CL_GL_OBJECT_TEXTURE3D 0x2002 +#define CL_GL_OBJECT_RENDERBUFFER 0x2003 + +/* cl_gl_texture_info */ +#define CL_GL_TEXTURE_TARGET 0x2004 +#define CL_GL_MIPMAP_LEVEL 0x2005 + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromGLBuffer(cl_context /* context */, + cl_mem_flags /* flags */, + cl_GLuint /* bufobj */, + int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromGLTexture2D(cl_context /* context */, + cl_mem_flags /* flags */, + cl_GLenum /* target */, + cl_GLint /* miplevel */, + cl_GLuint /* texture */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromGLTexture3D(cl_context /* context */, + cl_mem_flags /* flags */, + cl_GLenum /* target */, + cl_GLint /* miplevel */, + cl_GLuint /* texture */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromGLRenderbuffer(cl_context /* context */, + cl_mem_flags /* flags */, + cl_GLuint /* renderbuffer */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetGLObjectInfo(cl_mem /* memobj */, + cl_gl_object_type * /* gl_object_type */, + cl_GLuint * /* gl_object_name */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetGLTextureInfo(cl_mem /* memobj */, + cl_gl_texture_info /* param_name */, + size_t /* param_value_size */, + void * /* param_value */, + size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueAcquireGLObjects(cl_command_queue /* command_queue */, + cl_uint /* num_objects */, + const cl_mem * /* mem_objects */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReleaseGLObjects(cl_command_queue /* command_queue */, + cl_uint /* num_objects */, + const cl_mem * /* mem_objects */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; + +/* cl_khr_gl_sharing extension */ + +#define cl_khr_gl_sharing 1 + +typedef cl_uint cl_gl_context_info; + +/* Additional Error Codes */ +#define CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR -1000 + +/* cl_gl_context_info */ +#define CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR 0x2006 +#define CL_DEVICES_FOR_GL_CONTEXT_KHR 0x2007 + +/* Additional cl_context_properties */ +#define CL_GL_CONTEXT_KHR 0x2008 +#define CL_EGL_DISPLAY_KHR 0x2009 +#define CL_GLX_DISPLAY_KHR 0x200A +#define CL_WGL_HDC_KHR 0x200B +#define CL_CGL_SHAREGROUP_KHR 0x200C + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetGLContextInfoKHR(const cl_context_properties * /* properties */, + cl_gl_context_info /* param_name */, + size_t /* param_value_size */, + void * /* param_value */, + size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; + +typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetGLContextInfoKHR_fn)( + const cl_context_properties * properties, + cl_gl_context_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret); + +#ifdef __cplusplus +} +#endif + +#endif /* __OPENCL_CL_GL_H */ diff --git a/src/native/common/CL/cl_gl_ext.h b/src/native/common/CL/cl_gl_ext.h new file mode 100644 index 00000000..26e47821 --- /dev/null +++ b/src/native/common/CL/cl_gl_ext.h @@ -0,0 +1,69 @@ +/********************************************************************************** + * Copyright (c) 2008-2010 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and/or associated documentation files (the + * "Materials"), to deal in the Materials without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Materials, and to + * permit persons to whom the Materials are furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + **********************************************************************************/ + +/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */ + +/* cl_gl_ext.h contains vendor (non-KHR) OpenCL extensions which have */ +/* OpenGL dependencies. */ + +#ifndef __OPENCL_CL_GL_EXT_H +#define __OPENCL_CL_GL_EXT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __APPLE__ + #include +#else + #include +#endif + +/* + * For each extension, follow this template + * /* cl_VEN_extname extension */ +/* #define cl_VEN_extname 1 + * ... define new types, if any + * ... define new tokens, if any + * ... define new APIs, if any + * + * If you need GLtypes here, mirror them with a cl_GLtype, rather than including a GL header + * This allows us to avoid having to decide whether to include GL headers or GLES here. + */ + +/* + * cl_khr_gl_event extension + * See section 9.9 in the OpenCL 1.1 spec for more information + */ +#define CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR 0x200D + +extern CL_API_ENTRY cl_event CL_API_CALL +clCreateEventFromGLsyncKHR(cl_context /* context */, + cl_GLsync /* cl_GLsync */, + cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1; + +#ifdef __cplusplus +} +#endif + +#endif /* __OPENCL_CL_GL_EXT_H */ diff --git a/src/native/common/CL/cl_platform.h b/src/native/common/CL/cl_platform.h new file mode 100644 index 00000000..043b0489 --- /dev/null +++ b/src/native/common/CL/cl_platform.h @@ -0,0 +1,1198 @@ +/********************************************************************************** + * Copyright (c) 2008-2010 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and/or associated documentation files (the + * "Materials"), to deal in the Materials without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Materials, and to + * permit persons to whom the Materials are furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + **********************************************************************************/ + +/* $Revision: 11803 $ on $Date: 2010-06-25 10:02:12 -0700 (Fri, 25 Jun 2010) $ */ + +#ifndef __CL_PLATFORM_H +#define __CL_PLATFORM_H + +#ifdef __APPLE__ + /* Contains #defines for AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER below */ + #include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_WIN32) + #define CL_API_ENTRY + #define CL_API_CALL __stdcall + #define CL_CALLBACK __stdcall +#else + #define CL_API_ENTRY + #define CL_API_CALL + #define CL_CALLBACK +#endif + +#ifdef __APPLE__ + #define CL_EXTENSION_WEAK_LINK __attribute__((weak_import)) + #define CL_API_SUFFIX__VERSION_1_0 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER + #define CL_EXT_SUFFIX__VERSION_1_0 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER + #define CL_API_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK + #define CL_EXT_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK + #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#else + #define CL_EXTENSION_WEAK_LINK + #define CL_API_SUFFIX__VERSION_1_0 + #define CL_EXT_SUFFIX__VERSION_1_0 + #define CL_API_SUFFIX__VERSION_1_1 + #define CL_EXT_SUFFIX__VERSION_1_1 + #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED +#endif + +#if (defined (_WIN32) && defined(_MSC_VER)) + +/* scalar types */ +typedef signed __int8 cl_char; +typedef unsigned __int8 cl_uchar; +typedef signed __int16 cl_short; +typedef unsigned __int16 cl_ushort; +typedef signed __int32 cl_int; +typedef unsigned __int32 cl_uint; +typedef signed __int64 cl_long; +typedef unsigned __int64 cl_ulong; + +typedef unsigned __int16 cl_half; +typedef float cl_float; +typedef double cl_double; + +/* Macro names and corresponding values defined by OpenCL */ +#define CL_CHAR_BIT 8 +#define CL_SCHAR_MAX 127 +#define CL_SCHAR_MIN (-127-1) +#define CL_CHAR_MAX CL_SCHAR_MAX +#define CL_CHAR_MIN CL_SCHAR_MIN +#define CL_UCHAR_MAX 255 +#define CL_SHRT_MAX 32767 +#define CL_SHRT_MIN (-32767-1) +#define CL_USHRT_MAX 65535 +#define CL_INT_MAX 2147483647 +#define CL_INT_MIN (-2147483647-1) +#define CL_UINT_MAX 0xffffffffU +#define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL) +#define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL) +#define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL) + +#define CL_FLT_DIG 6 +#define CL_FLT_MANT_DIG 24 +#define CL_FLT_MAX_10_EXP +38 +#define CL_FLT_MAX_EXP +128 +#define CL_FLT_MIN_10_EXP -37 +#define CL_FLT_MIN_EXP -125 +#define CL_FLT_RADIX 2 +#define CL_FLT_MAX 340282346638528859811704183484516925440.0f +#define CL_FLT_MIN 1.175494350822287507969e-38f +#define CL_FLT_EPSILON 0x1.0p-23f + +#define CL_DBL_DIG 15 +#define CL_DBL_MANT_DIG 53 +#define CL_DBL_MAX_10_EXP +308 +#define CL_DBL_MAX_EXP +1024 +#define CL_DBL_MIN_10_EXP -307 +#define CL_DBL_MIN_EXP -1021 +#define CL_DBL_RADIX 2 +#define CL_DBL_MAX 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0 +#define CL_DBL_MIN 2.225073858507201383090e-308 +#define CL_DBL_EPSILON 2.220446049250313080847e-16 + +#define CL_M_E 2.718281828459045090796 +#define CL_M_LOG2E 1.442695040888963387005 +#define CL_M_LOG10E 0.434294481903251816668 +#define CL_M_LN2 0.693147180559945286227 +#define CL_M_LN10 2.302585092994045901094 +#define CL_M_PI 3.141592653589793115998 +#define CL_M_PI_2 1.570796326794896557999 +#define CL_M_PI_4 0.785398163397448278999 +#define CL_M_1_PI 0.318309886183790691216 +#define CL_M_2_PI 0.636619772367581382433 +#define CL_M_2_SQRTPI 1.128379167095512558561 +#define CL_M_SQRT2 1.414213562373095145475 +#define CL_M_SQRT1_2 0.707106781186547572737 + +#define CL_M_E_F 2.71828174591064f +#define CL_M_LOG2E_F 1.44269502162933f +#define CL_M_LOG10E_F 0.43429449200630f +#define CL_M_LN2_F 0.69314718246460f +#define CL_M_LN10_F 2.30258512496948f +#define CL_M_PI_F 3.14159274101257f +#define CL_M_PI_2_F 1.57079637050629f +#define CL_M_PI_4_F 0.78539818525314f +#define CL_M_1_PI_F 0.31830987334251f +#define CL_M_2_PI_F 0.63661974668503f +#define CL_M_2_SQRTPI_F 1.12837922573090f +#define CL_M_SQRT2_F 1.41421353816986f +#define CL_M_SQRT1_2_F 0.70710676908493f + +#define CL_NAN (CL_INFINITY - CL_INFINITY) +#define CL_HUGE_VALF ((cl_float) 1e50) +#define CL_HUGE_VAL ((cl_double) 1e500) +#define CL_MAXFLOAT CL_FLT_MAX +#define CL_INFINITY CL_HUGE_VALF + +#else + +#include + +/* scalar types */ +typedef int8_t cl_char; +typedef uint8_t cl_uchar; +typedef int16_t cl_short __attribute__((aligned(2))); +typedef uint16_t cl_ushort __attribute__((aligned(2))); +typedef int32_t cl_int __attribute__((aligned(4))); +typedef uint32_t cl_uint __attribute__((aligned(4))); +typedef int64_t cl_long __attribute__((aligned(8))); +typedef uint64_t cl_ulong __attribute__((aligned(8))); + +typedef uint16_t cl_half __attribute__((aligned(2))); +typedef float cl_float __attribute__((aligned(4))); +typedef double cl_double __attribute__((aligned(8))); + +/* Macro names and corresponding values defined by OpenCL */ +#define CL_CHAR_BIT 8 +#define CL_SCHAR_MAX 127 +#define CL_SCHAR_MIN (-127-1) +#define CL_CHAR_MAX CL_SCHAR_MAX +#define CL_CHAR_MIN CL_SCHAR_MIN +#define CL_UCHAR_MAX 255 +#define CL_SHRT_MAX 32767 +#define CL_SHRT_MIN (-32767-1) +#define CL_USHRT_MAX 65535 +#define CL_INT_MAX 2147483647 +#define CL_INT_MIN (-2147483647-1) +#define CL_UINT_MAX 0xffffffffU +#define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL) +#define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL) +#define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL) + +#define CL_FLT_DIG 6 +#define CL_FLT_MANT_DIG 24 +#define CL_FLT_MAX_10_EXP +38 +#define CL_FLT_MAX_EXP +128 +#define CL_FLT_MIN_10_EXP -37 +#define CL_FLT_MIN_EXP -125 +#define CL_FLT_RADIX 2 +#define CL_FLT_MAX 0x1.fffffep127f +#define CL_FLT_MIN 0x1.0p-126f +#define CL_FLT_EPSILON 0x1.0p-23f + +#define CL_DBL_DIG 15 +#define CL_DBL_MANT_DIG 53 +#define CL_DBL_MAX_10_EXP +308 +#define CL_DBL_MAX_EXP +1024 +#define CL_DBL_MIN_10_EXP -307 +#define CL_DBL_MIN_EXP -1021 +#define CL_DBL_RADIX 2 +#define CL_DBL_MAX 0x1.fffffffffffffp1023 +#define CL_DBL_MIN 0x1.0p-1022 +#define CL_DBL_EPSILON 0x1.0p-52 + +#define CL_M_E 2.718281828459045090796 +#define CL_M_LOG2E 1.442695040888963387005 +#define CL_M_LOG10E 0.434294481903251816668 +#define CL_M_LN2 0.693147180559945286227 +#define CL_M_LN10 2.302585092994045901094 +#define CL_M_PI 3.141592653589793115998 +#define CL_M_PI_2 1.570796326794896557999 +#define CL_M_PI_4 0.785398163397448278999 +#define CL_M_1_PI 0.318309886183790691216 +#define CL_M_2_PI 0.636619772367581382433 +#define CL_M_2_SQRTPI 1.128379167095512558561 +#define CL_M_SQRT2 1.414213562373095145475 +#define CL_M_SQRT1_2 0.707106781186547572737 + +#define CL_M_E_F 2.71828174591064f +#define CL_M_LOG2E_F 1.44269502162933f +#define CL_M_LOG10E_F 0.43429449200630f +#define CL_M_LN2_F 0.69314718246460f +#define CL_M_LN10_F 2.30258512496948f +#define CL_M_PI_F 3.14159274101257f +#define CL_M_PI_2_F 1.57079637050629f +#define CL_M_PI_4_F 0.78539818525314f +#define CL_M_1_PI_F 0.31830987334251f +#define CL_M_2_PI_F 0.63661974668503f +#define CL_M_2_SQRTPI_F 1.12837922573090f +#define CL_M_SQRT2_F 1.41421353816986f +#define CL_M_SQRT1_2_F 0.70710676908493f + +#if defined( __GNUC__ ) + #define CL_HUGE_VALF __builtin_huge_valf() + #define CL_HUGE_VAL __builtin_huge_val() + #define CL_NAN __builtin_nanf( "" ) +#else + #define CL_HUGE_VALF ((cl_float) 1e50) + #define CL_HUGE_VAL ((cl_double) 1e500) + float nanf( const char * ); + #define CL_NAN nanf( "" ) +#endif +#define CL_MAXFLOAT CL_FLT_MAX +#define CL_INFINITY CL_HUGE_VALF + +#endif + +#include + +/* Mirror types to GL types. Mirror types allow us to avoid deciding which headers to load based on whether we are using GL or GLES here. */ +typedef unsigned int cl_GLuint; +typedef int cl_GLint; +typedef unsigned int cl_GLenum; + +/* + * Vector types + * + * Note: OpenCL requires that all types be naturally aligned. + * This means that vector types must be naturally aligned. + * For example, a vector of four floats must be aligned to + * a 16 byte boundary (calculated as 4 * the natural 4-byte + * alignment of the float). The alignment qualifiers here + * will only function properly if your compiler supports them + * and if you don't actively work to defeat them. For example, + * in order for a cl_float4 to be 16 byte aligned in a struct, + * the start of the struct must itself be 16-byte aligned. + * + * Maintaining proper alignment is the user's responsibility. + */ + +/* Define basic vector types */ +#if defined( __VEC__ ) + #include /* may be omitted depending on compiler. AltiVec spec provides no way to detect whether the header is required. */ + typedef vector unsigned char __cl_uchar16; + typedef vector signed char __cl_char16; + typedef vector unsigned short __cl_ushort8; + typedef vector signed short __cl_short8; + typedef vector unsigned int __cl_uint4; + typedef vector signed int __cl_int4; + typedef vector float __cl_float4; + #define __CL_UCHAR16__ 1 + #define __CL_CHAR16__ 1 + #define __CL_USHORT8__ 1 + #define __CL_SHORT8__ 1 + #define __CL_UINT4__ 1 + #define __CL_INT4__ 1 + #define __CL_FLOAT4__ 1 +#endif + +#if defined( __SSE__ ) + #if defined( __MINGW64__ ) + #include + #else + #include + #endif + #if defined( __GNUC__ ) + typedef float __cl_float4 __attribute__((vector_size(16))); + #else + typedef __m128 __cl_float4; + #endif + #define __CL_FLOAT4__ 1 +#endif + +#if defined( __SSE2__ ) + #if defined( __MINGW64__ ) + #include + #else + #include + #endif + #if defined( __GNUC__ ) + typedef cl_uchar __cl_uchar16 __attribute__((vector_size(16))); + typedef cl_char __cl_char16 __attribute__((vector_size(16))); + typedef cl_ushort __cl_ushort8 __attribute__((vector_size(16))); + typedef cl_short __cl_short8 __attribute__((vector_size(16))); + typedef cl_uint __cl_uint4 __attribute__((vector_size(16))); + typedef cl_int __cl_int4 __attribute__((vector_size(16))); + typedef cl_ulong __cl_ulong2 __attribute__((vector_size(16))); + typedef cl_long __cl_long2 __attribute__((vector_size(16))); + typedef cl_double __cl_double2 __attribute__((vector_size(16))); + #else + typedef __m128i __cl_uchar16; + typedef __m128i __cl_char16; + typedef __m128i __cl_ushort8; + typedef __m128i __cl_short8; + typedef __m128i __cl_uint4; + typedef __m128i __cl_int4; + typedef __m128i __cl_ulong2; + typedef __m128i __cl_long2; + typedef __m128d __cl_double2; + #endif + #define __CL_UCHAR16__ 1 + #define __CL_CHAR16__ 1 + #define __CL_USHORT8__ 1 + #define __CL_SHORT8__ 1 + #define __CL_INT4__ 1 + #define __CL_UINT4__ 1 + #define __CL_ULONG2__ 1 + #define __CL_LONG2__ 1 + #define __CL_DOUBLE2__ 1 +#endif + +#if defined( __MMX__ ) + #include + #if defined( __GNUC__ ) + typedef cl_uchar __cl_uchar8 __attribute__((vector_size(8))); + typedef cl_char __cl_char8 __attribute__((vector_size(8))); + typedef cl_ushort __cl_ushort4 __attribute__((vector_size(8))); + typedef cl_short __cl_short4 __attribute__((vector_size(8))); + typedef cl_uint __cl_uint2 __attribute__((vector_size(8))); + typedef cl_int __cl_int2 __attribute__((vector_size(8))); + typedef cl_ulong __cl_ulong1 __attribute__((vector_size(8))); + typedef cl_long __cl_long1 __attribute__((vector_size(8))); + typedef cl_float __cl_float2 __attribute__((vector_size(8))); + #else + typedef __m64 __cl_uchar8; + typedef __m64 __cl_char8; + typedef __m64 __cl_ushort4; + typedef __m64 __cl_short4; + typedef __m64 __cl_uint2; + typedef __m64 __cl_int2; + typedef __m64 __cl_ulong1; + typedef __m64 __cl_long1; + typedef __m64 __cl_float2; + #endif + #define __CL_UCHAR8__ 1 + #define __CL_CHAR8__ 1 + #define __CL_USHORT4__ 1 + #define __CL_SHORT4__ 1 + #define __CL_INT2__ 1 + #define __CL_UINT2__ 1 + #define __CL_ULONG1__ 1 + #define __CL_LONG1__ 1 + #define __CL_FLOAT2__ 1 +#endif + +#if defined( __AVX__ ) + #if defined( __MINGW64__ ) + #include + #else + #include + #endif + #if defined( __GNUC__ ) + typedef cl_float __cl_float8 __attribute__((vector_size(32))); + typedef cl_double __cl_double4 __attribute__((vector_size(32))); + #else + typedef __m256 __cl_float8; + typedef __m256d __cl_double4; + #endif + #define __CL_FLOAT8__ 1 + #define __CL_DOUBLE4__ 1 +#endif + +/* Define alignment keys */ +#if defined( __GNUC__ ) + #define CL_ALIGNED(_x) __attribute__ ((aligned(_x))) +#elif defined( _WIN32) && (_MSC_VER) + /* Alignment keys neutered on windows because MSVC can't swallow function arguments with alignment requirements */ + /* http://msdn.microsoft.com/en-us/library/373ak2y1%28VS.71%29.aspx */ + /* #include */ + /* #define CL_ALIGNED(_x) _CRT_ALIGN(_x) */ + #define CL_ALIGNED(_x) +#else + #warning Need to implement some method to align data here + #define CL_ALIGNED(_x) +#endif + +/* Indicate whether .xyzw, .s0123 and .hi.lo are supported */ +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + /* .xyzw and .s0123...{f|F} are supported */ + #define CL_HAS_NAMED_VECTOR_FIELDS 1 + /* .hi and .lo are supported */ + #define CL_HAS_HI_LO_VECTOR_FIELDS 1 +#endif + +/* Define cl_vector types */ + +/* ---- cl_charn ---- */ +typedef union +{ + cl_char CL_ALIGNED(2) s[2]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_char x, y; }; + __extension__ struct{ cl_char s0, s1; }; + __extension__ struct{ cl_char lo, hi; }; +#endif +#if defined( __CL_CHAR2__) + __cl_char2 v2; +#endif +}cl_char2; + +typedef union +{ + cl_char CL_ALIGNED(4) s[4]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_char x, y, z, w; }; + __extension__ struct{ cl_char s0, s1, s2, s3; }; + __extension__ struct{ cl_char2 lo, hi; }; +#endif +#if defined( __CL_CHAR2__) + __cl_char2 v2[2]; +#endif +#if defined( __CL_CHAR4__) + __cl_char4 v4; +#endif +}cl_char4; + +/* cl_char3 is identical in size, alignment and behavior to cl_char4. See section 6.1.5. */ +typedef cl_char4 cl_char3; + +typedef union +{ + cl_char CL_ALIGNED(8) s[8]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_char x, y, z, w; }; + __extension__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7; }; + __extension__ struct{ cl_char4 lo, hi; }; +#endif +#if defined( __CL_CHAR2__) + __cl_char2 v2[4]; +#endif +#if defined( __CL_CHAR4__) + __cl_char4 v4[2]; +#endif +#if defined( __CL_CHAR8__ ) + __cl_char8 v8; +#endif +}cl_char8; + +typedef union +{ + cl_char CL_ALIGNED(16) s[16]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_char x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; + __extension__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; + __extension__ struct{ cl_char8 lo, hi; }; +#endif +#if defined( __CL_CHAR2__) + __cl_char2 v2[8]; +#endif +#if defined( __CL_CHAR4__) + __cl_char4 v4[4]; +#endif +#if defined( __CL_CHAR8__ ) + __cl_char8 v8[2]; +#endif +#if defined( __CL_CHAR16__ ) + __cl_char16 v16; +#endif +}cl_char16; + + +/* ---- cl_ucharn ---- */ +typedef union +{ + cl_uchar CL_ALIGNED(2) s[2]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_uchar x, y; }; + __extension__ struct{ cl_uchar s0, s1; }; + __extension__ struct{ cl_uchar lo, hi; }; +#endif +#if defined( __cl_uchar2__) + __cl_uchar2 v2; +#endif +}cl_uchar2; + +typedef union +{ + cl_uchar CL_ALIGNED(4) s[4]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_uchar x, y, z, w; }; + __extension__ struct{ cl_uchar s0, s1, s2, s3; }; + __extension__ struct{ cl_uchar2 lo, hi; }; +#endif +#if defined( __CL_UCHAR2__) + __cl_uchar2 v2[2]; +#endif +#if defined( __CL_UCHAR4__) + __cl_uchar4 v4; +#endif +}cl_uchar4; + +/* cl_uchar3 is identical in size, alignment and behavior to cl_uchar4. See section 6.1.5. */ +typedef cl_uchar4 cl_uchar3; + +typedef union +{ + cl_uchar CL_ALIGNED(8) s[8]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_uchar x, y, z, w; }; + __extension__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7; }; + __extension__ struct{ cl_uchar4 lo, hi; }; +#endif +#if defined( __CL_UCHAR2__) + __cl_uchar2 v2[4]; +#endif +#if defined( __CL_UCHAR4__) + __cl_uchar4 v4[2]; +#endif +#if defined( __CL_UCHAR8__ ) + __cl_uchar8 v8; +#endif +}cl_uchar8; + +typedef union +{ + cl_uchar CL_ALIGNED(16) s[16]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_uchar x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; + __extension__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; + __extension__ struct{ cl_uchar8 lo, hi; }; +#endif +#if defined( __CL_UCHAR2__) + __cl_uchar2 v2[8]; +#endif +#if defined( __CL_UCHAR4__) + __cl_uchar4 v4[4]; +#endif +#if defined( __CL_UCHAR8__ ) + __cl_uchar8 v8[2]; +#endif +#if defined( __CL_UCHAR16__ ) + __cl_uchar16 v16; +#endif +}cl_uchar16; + + +/* ---- cl_shortn ---- */ +typedef union +{ + cl_short CL_ALIGNED(4) s[2]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_short x, y; }; + __extension__ struct{ cl_short s0, s1; }; + __extension__ struct{ cl_short lo, hi; }; +#endif +#if defined( __CL_SHORT2__) + __cl_short2 v2; +#endif +}cl_short2; + +typedef union +{ + cl_short CL_ALIGNED(8) s[4]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_short x, y, z, w; }; + __extension__ struct{ cl_short s0, s1, s2, s3; }; + __extension__ struct{ cl_short2 lo, hi; }; +#endif +#if defined( __CL_SHORT2__) + __cl_short2 v2[2]; +#endif +#if defined( __CL_SHORT4__) + __cl_short4 v4; +#endif +}cl_short4; + +/* cl_short3 is identical in size, alignment and behavior to cl_short4. See section 6.1.5. */ +typedef cl_short4 cl_short3; + +typedef union +{ + cl_short CL_ALIGNED(16) s[8]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_short x, y, z, w; }; + __extension__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7; }; + __extension__ struct{ cl_short4 lo, hi; }; +#endif +#if defined( __CL_SHORT2__) + __cl_short2 v2[4]; +#endif +#if defined( __CL_SHORT4__) + __cl_short4 v4[2]; +#endif +#if defined( __CL_SHORT8__ ) + __cl_short8 v8; +#endif +}cl_short8; + +typedef union +{ + cl_short CL_ALIGNED(32) s[16]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_short x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; + __extension__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; + __extension__ struct{ cl_short8 lo, hi; }; +#endif +#if defined( __CL_SHORT2__) + __cl_short2 v2[8]; +#endif +#if defined( __CL_SHORT4__) + __cl_short4 v4[4]; +#endif +#if defined( __CL_SHORT8__ ) + __cl_short8 v8[2]; +#endif +#if defined( __CL_SHORT16__ ) + __cl_short16 v16; +#endif +}cl_short16; + + +/* ---- cl_ushortn ---- */ +typedef union +{ + cl_ushort CL_ALIGNED(4) s[2]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_ushort x, y; }; + __extension__ struct{ cl_ushort s0, s1; }; + __extension__ struct{ cl_ushort lo, hi; }; +#endif +#if defined( __CL_USHORT2__) + __cl_ushort2 v2; +#endif +}cl_ushort2; + +typedef union +{ + cl_ushort CL_ALIGNED(8) s[4]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_ushort x, y, z, w; }; + __extension__ struct{ cl_ushort s0, s1, s2, s3; }; + __extension__ struct{ cl_ushort2 lo, hi; }; +#endif +#if defined( __CL_USHORT2__) + __cl_ushort2 v2[2]; +#endif +#if defined( __CL_USHORT4__) + __cl_ushort4 v4; +#endif +}cl_ushort4; + +/* cl_ushort3 is identical in size, alignment and behavior to cl_ushort4. See section 6.1.5. */ +typedef cl_ushort4 cl_ushort3; + +typedef union +{ + cl_ushort CL_ALIGNED(16) s[8]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_ushort x, y, z, w; }; + __extension__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7; }; + __extension__ struct{ cl_ushort4 lo, hi; }; +#endif +#if defined( __CL_USHORT2__) + __cl_ushort2 v2[4]; +#endif +#if defined( __CL_USHORT4__) + __cl_ushort4 v4[2]; +#endif +#if defined( __CL_USHORT8__ ) + __cl_ushort8 v8; +#endif +}cl_ushort8; + +typedef union +{ + cl_ushort CL_ALIGNED(32) s[16]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_ushort x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; + __extension__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; + __extension__ struct{ cl_ushort8 lo, hi; }; +#endif +#if defined( __CL_USHORT2__) + __cl_ushort2 v2[8]; +#endif +#if defined( __CL_USHORT4__) + __cl_ushort4 v4[4]; +#endif +#if defined( __CL_USHORT8__ ) + __cl_ushort8 v8[2]; +#endif +#if defined( __CL_USHORT16__ ) + __cl_ushort16 v16; +#endif +}cl_ushort16; + +/* ---- cl_intn ---- */ +typedef union +{ + cl_int CL_ALIGNED(8) s[2]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_int x, y; }; + __extension__ struct{ cl_int s0, s1; }; + __extension__ struct{ cl_int lo, hi; }; +#endif +#if defined( __CL_INT2__) + __cl_int2 v2; +#endif +}cl_int2; + +typedef union +{ + cl_int CL_ALIGNED(16) s[4]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_int x, y, z, w; }; + __extension__ struct{ cl_int s0, s1, s2, s3; }; + __extension__ struct{ cl_int2 lo, hi; }; +#endif +#if defined( __CL_INT2__) + __cl_int2 v2[2]; +#endif +#if defined( __CL_INT4__) + __cl_int4 v4; +#endif +}cl_int4; + +/* cl_int3 is identical in size, alignment and behavior to cl_int4. See section 6.1.5. */ +typedef cl_int4 cl_int3; + +typedef union +{ + cl_int CL_ALIGNED(32) s[8]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_int x, y, z, w; }; + __extension__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7; }; + __extension__ struct{ cl_int4 lo, hi; }; +#endif +#if defined( __CL_INT2__) + __cl_int2 v2[4]; +#endif +#if defined( __CL_INT4__) + __cl_int4 v4[2]; +#endif +#if defined( __CL_INT8__ ) + __cl_int8 v8; +#endif +}cl_int8; + +typedef union +{ + cl_int CL_ALIGNED(64) s[16]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_int x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; + __extension__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; + __extension__ struct{ cl_int8 lo, hi; }; +#endif +#if defined( __CL_INT2__) + __cl_int2 v2[8]; +#endif +#if defined( __CL_INT4__) + __cl_int4 v4[4]; +#endif +#if defined( __CL_INT8__ ) + __cl_int8 v8[2]; +#endif +#if defined( __CL_INT16__ ) + __cl_int16 v16; +#endif +}cl_int16; + + +/* ---- cl_uintn ---- */ +typedef union +{ + cl_uint CL_ALIGNED(8) s[2]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_uint x, y; }; + __extension__ struct{ cl_uint s0, s1; }; + __extension__ struct{ cl_uint lo, hi; }; +#endif +#if defined( __CL_UINT2__) + __cl_uint2 v2; +#endif +}cl_uint2; + +typedef union +{ + cl_uint CL_ALIGNED(16) s[4]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_uint x, y, z, w; }; + __extension__ struct{ cl_uint s0, s1, s2, s3; }; + __extension__ struct{ cl_uint2 lo, hi; }; +#endif +#if defined( __CL_UINT2__) + __cl_uint2 v2[2]; +#endif +#if defined( __CL_UINT4__) + __cl_uint4 v4; +#endif +}cl_uint4; + +/* cl_uint3 is identical in size, alignment and behavior to cl_uint4. See section 6.1.5. */ +typedef cl_uint4 cl_uint3; + +typedef union +{ + cl_uint CL_ALIGNED(32) s[8]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_uint x, y, z, w; }; + __extension__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7; }; + __extension__ struct{ cl_uint4 lo, hi; }; +#endif +#if defined( __CL_UINT2__) + __cl_uint2 v2[4]; +#endif +#if defined( __CL_UINT4__) + __cl_uint4 v4[2]; +#endif +#if defined( __CL_UINT8__ ) + __cl_uint8 v8; +#endif +}cl_uint8; + +typedef union +{ + cl_uint CL_ALIGNED(64) s[16]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_uint x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; + __extension__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; + __extension__ struct{ cl_uint8 lo, hi; }; +#endif +#if defined( __CL_UINT2__) + __cl_uint2 v2[8]; +#endif +#if defined( __CL_UINT4__) + __cl_uint4 v4[4]; +#endif +#if defined( __CL_UINT8__ ) + __cl_uint8 v8[2]; +#endif +#if defined( __CL_UINT16__ ) + __cl_uint16 v16; +#endif +}cl_uint16; + +/* ---- cl_longn ---- */ +typedef union +{ + cl_long CL_ALIGNED(16) s[2]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_long x, y; }; + __extension__ struct{ cl_long s0, s1; }; + __extension__ struct{ cl_long lo, hi; }; +#endif +#if defined( __CL_LONG2__) + __cl_long2 v2; +#endif +}cl_long2; + +typedef union +{ + cl_long CL_ALIGNED(32) s[4]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_long x, y, z, w; }; + __extension__ struct{ cl_long s0, s1, s2, s3; }; + __extension__ struct{ cl_long2 lo, hi; }; +#endif +#if defined( __CL_LONG2__) + __cl_long2 v2[2]; +#endif +#if defined( __CL_LONG4__) + __cl_long4 v4; +#endif +}cl_long4; + +/* cl_long3 is identical in size, alignment and behavior to cl_long4. See section 6.1.5. */ +typedef cl_long4 cl_long3; + +typedef union +{ + cl_long CL_ALIGNED(64) s[8]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_long x, y, z, w; }; + __extension__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7; }; + __extension__ struct{ cl_long4 lo, hi; }; +#endif +#if defined( __CL_LONG2__) + __cl_long2 v2[4]; +#endif +#if defined( __CL_LONG4__) + __cl_long4 v4[2]; +#endif +#if defined( __CL_LONG8__ ) + __cl_long8 v8; +#endif +}cl_long8; + +typedef union +{ + cl_long CL_ALIGNED(128) s[16]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_long x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; + __extension__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; + __extension__ struct{ cl_long8 lo, hi; }; +#endif +#if defined( __CL_LONG2__) + __cl_long2 v2[8]; +#endif +#if defined( __CL_LONG4__) + __cl_long4 v4[4]; +#endif +#if defined( __CL_LONG8__ ) + __cl_long8 v8[2]; +#endif +#if defined( __CL_LONG16__ ) + __cl_long16 v16; +#endif +}cl_long16; + + +/* ---- cl_ulongn ---- */ +typedef union +{ + cl_ulong CL_ALIGNED(16) s[2]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_ulong x, y; }; + __extension__ struct{ cl_ulong s0, s1; }; + __extension__ struct{ cl_ulong lo, hi; }; +#endif +#if defined( __CL_ULONG2__) + __cl_ulong2 v2; +#endif +}cl_ulong2; + +typedef union +{ + cl_ulong CL_ALIGNED(32) s[4]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_ulong x, y, z, w; }; + __extension__ struct{ cl_ulong s0, s1, s2, s3; }; + __extension__ struct{ cl_ulong2 lo, hi; }; +#endif +#if defined( __CL_ULONG2__) + __cl_ulong2 v2[2]; +#endif +#if defined( __CL_ULONG4__) + __cl_ulong4 v4; +#endif +}cl_ulong4; + +/* cl_ulong3 is identical in size, alignment and behavior to cl_ulong4. See section 6.1.5. */ +typedef cl_ulong4 cl_ulong3; + +typedef union +{ + cl_ulong CL_ALIGNED(64) s[8]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_ulong x, y, z, w; }; + __extension__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7; }; + __extension__ struct{ cl_ulong4 lo, hi; }; +#endif +#if defined( __CL_ULONG2__) + __cl_ulong2 v2[4]; +#endif +#if defined( __CL_ULONG4__) + __cl_ulong4 v4[2]; +#endif +#if defined( __CL_ULONG8__ ) + __cl_ulong8 v8; +#endif +}cl_ulong8; + +typedef union +{ + cl_ulong CL_ALIGNED(128) s[16]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_ulong x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; + __extension__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; + __extension__ struct{ cl_ulong8 lo, hi; }; +#endif +#if defined( __CL_ULONG2__) + __cl_ulong2 v2[8]; +#endif +#if defined( __CL_ULONG4__) + __cl_ulong4 v4[4]; +#endif +#if defined( __CL_ULONG8__ ) + __cl_ulong8 v8[2]; +#endif +#if defined( __CL_ULONG16__ ) + __cl_ulong16 v16; +#endif +}cl_ulong16; + + +/* --- cl_floatn ---- */ + +typedef union +{ + cl_float CL_ALIGNED(8) s[2]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_float x, y; }; + __extension__ struct{ cl_float s0, s1; }; + __extension__ struct{ cl_float lo, hi; }; +#endif +#if defined( __CL_FLOAT2__) + __cl_float2 v2; +#endif +}cl_float2; + +typedef union +{ + cl_float CL_ALIGNED(16) s[4]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_float x, y, z, w; }; + __extension__ struct{ cl_float s0, s1, s2, s3; }; + __extension__ struct{ cl_float2 lo, hi; }; +#endif +#if defined( __CL_FLOAT2__) + __cl_float2 v2[2]; +#endif +#if defined( __CL_FLOAT4__) + __cl_float4 v4; +#endif +}cl_float4; + +/* cl_float3 is identical in size, alignment and behavior to cl_float4. See section 6.1.5. */ +typedef cl_float4 cl_float3; + +typedef union +{ + cl_float CL_ALIGNED(32) s[8]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_float x, y, z, w; }; + __extension__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7; }; + __extension__ struct{ cl_float4 lo, hi; }; +#endif +#if defined( __CL_FLOAT2__) + __cl_float2 v2[4]; +#endif +#if defined( __CL_FLOAT4__) + __cl_float4 v4[2]; +#endif +#if defined( __CL_FLOAT8__ ) + __cl_float8 v8; +#endif +}cl_float8; + +typedef union +{ + cl_float CL_ALIGNED(64) s[16]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_float x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; + __extension__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; + __extension__ struct{ cl_float8 lo, hi; }; +#endif +#if defined( __CL_FLOAT2__) + __cl_float2 v2[8]; +#endif +#if defined( __CL_FLOAT4__) + __cl_float4 v4[4]; +#endif +#if defined( __CL_FLOAT8__ ) + __cl_float8 v8[2]; +#endif +#if defined( __CL_FLOAT16__ ) + __cl_float16 v16; +#endif +}cl_float16; + +/* --- cl_doublen ---- */ + +typedef union +{ + cl_double CL_ALIGNED(16) s[2]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_double x, y; }; + __extension__ struct{ cl_double s0, s1; }; + __extension__ struct{ cl_double lo, hi; }; +#endif +#if defined( __CL_DOUBLE2__) + __cl_double2 v2; +#endif +}cl_double2; + +typedef union +{ + cl_double CL_ALIGNED(32) s[4]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_double x, y, z, w; }; + __extension__ struct{ cl_double s0, s1, s2, s3; }; + __extension__ struct{ cl_double2 lo, hi; }; +#endif +#if defined( __CL_DOUBLE2__) + __cl_double2 v2[2]; +#endif +#if defined( __CL_DOUBLE4__) + __cl_double4 v4; +#endif +}cl_double4; + +/* cl_double3 is identical in size, alignment and behavior to cl_double4. See section 6.1.5. */ +typedef cl_double4 cl_double3; + +typedef union +{ + cl_double CL_ALIGNED(64) s[8]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_double x, y, z, w; }; + __extension__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7; }; + __extension__ struct{ cl_double4 lo, hi; }; +#endif +#if defined( __CL_DOUBLE2__) + __cl_double2 v2[4]; +#endif +#if defined( __CL_DOUBLE4__) + __cl_double4 v4[2]; +#endif +#if defined( __CL_DOUBLE8__ ) + __cl_double8 v8; +#endif +}cl_double8; + +typedef union +{ + cl_double CL_ALIGNED(128) s[16]; +#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) + __extension__ struct{ cl_double x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; + __extension__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; + __extension__ struct{ cl_double8 lo, hi; }; +#endif +#if defined( __CL_DOUBLE2__) + __cl_double2 v2[8]; +#endif +#if defined( __CL_DOUBLE4__) + __cl_double4 v4[4]; +#endif +#if defined( __CL_DOUBLE8__ ) + __cl_double8 v8[2]; +#endif +#if defined( __CL_DOUBLE16__ ) + __cl_double16 v16; +#endif +}cl_double16; + +/* Macro to facilitate debugging + * Usage: + * Place CL_PROGRAM_STRING_DEBUG_INFO on the line before the first line of your source. + * The first line ends with: CL_PROGRAM_STRING_BEGIN \" + * Each line thereafter of OpenCL C source must end with: \n\ + * The last line ends in "; + * + * Example: + * + * const char *my_program = CL_PROGRAM_STRING_BEGIN "\ + * kernel void foo( int a, float * b ) \n\ + * { \n\ + * // my comment \n\ + * *b[ get_global_id(0)] = a; \n\ + * } \n\ + * "; + * + * This should correctly set up the line, (column) and file information for your source + * string so you can do source level debugging. + */ +#define __CL_STRINGIFY( _x ) # _x +#define _CL_STRINGIFY( _x ) __CL_STRINGIFY( _x ) +#define CL_PROGRAM_STRING_DEBUG_INFO "#line " _CL_STRINGIFY(__LINE__) " \"" __FILE__ "\" \n\n" + +#ifdef __cplusplus +} +#endif + +#endif /* __CL_PLATFORM_H */ diff --git a/src/native/common/common_tools.c b/src/native/common/common_tools.c index d381ca56..7f17f972 100644 --- a/src/native/common/common_tools.c +++ b/src/native/common/common_tools.c @@ -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$ * @@ -45,6 +45,9 @@ static bool debug = false; static JavaVM *jvm; +static jmethodID mByteBuffer_asReadOnlyBuffer; +static jmethodID mPointerWrapper_getPointer; + void initAttribList(attrib_list_t *list) { list->current_index = 0; } @@ -175,41 +178,41 @@ void throwException(JNIEnv * env, const char * err) { } // retrieves the locale-specific C string -char * GetStringNativeChars(JNIEnv *env, jstring jstr) { - jbyteArray bytes = 0; - jthrowable exc; - char *result = 0; +char * GetStringNativeChars(JNIEnv *env, jstring jstr) { + jbyteArray bytes = 0; + jthrowable exc; + char *result = 0; jclass jcls_str; jmethodID MID_String_getBytes; - /* out of memory error? */ - if ((*env)->EnsureLocalCapacity(env, 2) < 0) { - return 0; - } + /* out of memory error? */ + if ((*env)->EnsureLocalCapacity(env, 2) < 0) { + return 0; + } // aquire getBytes method - jcls_str = (*env)->FindClass(env, "java/lang/String"); - MID_String_getBytes = (*env)->GetMethodID(env, jcls_str, "getBytes", "()[B"); + jcls_str = (*env)->FindClass(env, "java/lang/String"); + MID_String_getBytes = (*env)->GetMethodID(env, jcls_str, "getBytes", "()[B"); // get the bytes - bytes = (jbyteArray) (*env)->CallObjectMethod(env, jstr, MID_String_getBytes); - exc = (*env)->ExceptionOccurred(env); + bytes = (jbyteArray) (*env)->CallObjectMethod(env, jstr, MID_String_getBytes); + exc = (*env)->ExceptionOccurred(env); // if no exception occured while getting bytes - continue - if (!exc) { - jint len = (*env)->GetArrayLength(env, bytes); - result = (char *) malloc(len + 1); - if (result == 0) { - throwGeneralException(env, "java/lang/OutOfMemoryError", NULL); - (*env)->DeleteLocalRef(env, bytes); - return 0; - } - (*env)->GetByteArrayRegion(env, bytes, 0, len, (jbyte *) result); - result[len] = 0; /* NULL-terminate */ - } else { - (*env)->DeleteLocalRef(env, exc); - } - (*env)->DeleteLocalRef(env, bytes); + if (!exc) { + jint len = (*env)->GetArrayLength(env, bytes); + result = (char *) malloc(len + 1); + if (result == 0) { + throwGeneralException(env, "java/lang/OutOfMemoryError", NULL); + (*env)->DeleteLocalRef(env, bytes); + return 0; + } + (*env)->GetByteArrayRegion(env, bytes, 0, len, (jbyte *) result); + result[len] = 0; /* NULL-terminate */ + } else { + (*env)->DeleteLocalRef(env, exc); + } + (*env)->DeleteLocalRef(env, bytes); return (char*) result; } @@ -224,36 +227,36 @@ jstring NewStringNativeUnsigned(JNIEnv *env, const unsigned char *ustr) { } // creates locale specific string -jstring NewStringNativeWithLength(JNIEnv *env, const char *str, int length) { +jstring NewStringNativeWithLength(JNIEnv *env, const char *str, int length) { jclass jcls_str; jmethodID jmethod_str; - jstring result; + jstring result; jbyteArray bytes; - if (str==NULL) { - return NULL; - } - - jcls_str = (*env)->FindClass(env,"java/lang/String"); + if (str==NULL) { + return NULL; + } + + jcls_str = (*env)->FindClass(env,"java/lang/String"); if (jcls_str == NULL) return NULL; - jmethod_str = (*env)->GetMethodID(env,jcls_str, "", "([B)V"); + jmethod_str = (*env)->GetMethodID(env,jcls_str, "", "([B)V"); if (jmethod_str == NULL) return NULL; - bytes = 0; + bytes = 0; - if ((*env)->EnsureLocalCapacity(env,2) < 0) { - return NULL; /* out of memory error */ - } + if ((*env)->EnsureLocalCapacity(env,2) < 0) { + return NULL; /* out of memory error */ + } - bytes = (*env)->NewByteArray(env,length); - if (bytes != NULL) { - (*env)->SetByteArrayRegion(env,bytes, 0, length, (jbyte *)str); - result = (jstring)(*env)->NewObject(env,jcls_str, jmethod_str, bytes); - (*env)->DeleteLocalRef(env,bytes); - return result; - } /* else fall through */ - return NULL; + bytes = (*env)->NewByteArray(env,length); + if (bytes != NULL) { + (*env)->SetByteArrayRegion(env,bytes, 0, length, (jbyte *)str); + result = (jstring)(*env)->NewObject(env,jcls_str, jmethod_str, bytes); + (*env)->DeleteLocalRef(env,bytes); + return result; + } /* else fall through */ + return NULL; } bool ext_InitializeFunctions(ExtGetProcAddressPROC gpa, int num_functions, ExtFunction *functions) { @@ -272,6 +275,11 @@ bool ext_InitializeFunctions(ExtGetProcAddressPROC gpa, int num_functions, ExtFu return true; } +jobject NewReadOnlyDirectByteBuffer(JNIEnv* env, const void* address, jlong capacity) { + jobject buffer = (*env)->NewDirectByteBuffer(env, (void *)address, capacity); + return (*env)->CallObjectMethod(env, buffer, mByteBuffer_asReadOnlyBuffer); +} + jobject newJavaManagedByteBuffer(JNIEnv *env, const int size) { jclass bufferutils_class = (*env)->FindClass(env, "org/lwjgl/BufferUtils"); jmethodID createByteBuffer = (*env)->GetStaticMethodID(env, bufferutils_class, "createByteBuffer", "(I)Ljava/nio/ByteBuffer;"); @@ -327,15 +335,40 @@ bool getBooleanProperty(JNIEnv *env, const char* propertyName) { return (*env)->CallStaticBooleanMethod(env, org_lwjgl_LWJGLUtil_class, getBoolean, property) ? true : false; } +jlong getPointerWrapperAddress(JNIEnv *env, jobject wrapper) { + return (*env)->CallLongMethod(env, wrapper, mPointerWrapper_getPointer); +} + JNIEnv *getThreadEnv() { JNIEnv *env; (*jvm)->GetEnv(jvm, (void *)&env, JNI_VERSION_1_4); return env; } +JNIEnv *attachCurrentThread() { + JNIEnv *env; + (*jvm)->AttachCurrentThread(jvm, (void **)&env, NULL); + return env; +} + +void detachCurrentThread() { + (*jvm)->DetachCurrentThread(jvm); +} + JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { - jvm = vm; - return JNI_VERSION_1_4; + JNIEnv *env; + jclass clazz; + + jvm = vm; + env = getThreadEnv(); + + clazz = (*env)->FindClass(env, "java/nio/ByteBuffer"); + mByteBuffer_asReadOnlyBuffer = (*env)->GetMethodID(env, clazz, "asReadOnlyBuffer", "()Ljava/nio/ByteBuffer;"); + + clazz = (*env)->FindClass(env, "org/lwjgl/PointerWrapper"); + mPointerWrapper_getPointer = (*env)->GetMethodID(env, clazz, "getPointer", "()J"); + + return JNI_VERSION_1_4; } JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) { diff --git a/src/native/common/common_tools.h b/src/native/common/common_tools.h index 3fcd1f4d..49ba5980 100644 --- a/src/native/common/common_tools.h +++ b/src/native/common/common_tools.h @@ -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$ * @@ -123,6 +123,8 @@ extern "C" { #endif extern JNIEnv *getThreadEnv(); +extern JNIEnv *attachCurrentThread(); +extern void detachCurrentThread(); extern void initAttribList(attrib_list_t *list); extern void putAttrib(attrib_list_t *list, int attrib); @@ -140,8 +142,10 @@ extern bool getBooleanProperty(JNIEnv *env, const char* propertyName); extern char * GetStringNativeChars(JNIEnv *env, jstring jstr); extern jstring NewStringNativeWithLength(JNIEnv *env, const char *str, int length); extern jstring NewStringNativeUnsigned(JNIEnv *env, const unsigned char *str); +extern jobject NewReadOnlyDirectByteBuffer(JNIEnv* env, const void* address, jlong capacity); extern jobject newJavaManagedByteBuffer(JNIEnv *env, const int size); extern bool positionBuffer(JNIEnv *env, jobject buffer, jint position); +extern jlong getPointerWrapperAddress(JNIEnv *env, jobject wrapper); extern void ext_InitializeClass(JNIEnv *env, jclass clazz, ExtGetProcAddressPROC gpa, int num_functions, JavaMethodAndExtFunction *functions); extern bool ext_InitializeFunctions(ExtGetProcAddressPROC gpa, int num_functions, ExtFunction *functions); diff --git a/src/native/common/extal.c b/src/native/common/extal.c index a2b98b85..502e0707 100644 --- a/src/native/common/extal.c +++ b/src/native/common/extal.c @@ -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. */ - + #include #include "extal.h" @@ -42,13 +42,13 @@ typedef ALvoid* (ALAPIENTRY *alGetProcAddressPROC)(const ALubyte* fname); */ /*void InitializeOpenAL(JNIEnv *env, jstring oalPath) { //load our library - if (!tryLoadLibrary(env, oalPath)) { + if (!extal_LoadLibrary(env, oalPath)) { throwException(env, "Could not load openal library."); return; } - alGetProcAddress = (alGetProcAddressPROC)NativeGetFunctionPointer("alGetProcAddress"); + alGetProcAddress = (alGetProcAddressPROC)extal_NativeGetFunctionPointer("alGetProcAddress"); if (alGetProcAddress == NULL) { - UnLoadOpenAL(); + extal_UnloadLibrary(); throwException(env, "Could not load alGetProcAddress function pointer."); return; } @@ -64,7 +64,7 @@ void* extal_GetProcAddress(const char* function) { void *p; /* p = alGetProcAddress((const ALubyte*)function); if (p == NULL) {*/ - p = NativeGetFunctionPointer(function); + p = extal_NativeGetFunctionPointer(function); if (p == NULL) { printfDebug("Could not locate symbol %s\n", function); } diff --git a/src/native/common/extal.h b/src/native/common/extal.h index 1eac8830..7f14c18f 100644 --- a/src/native/common/extal.h +++ b/src/native/common/extal.h @@ -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. */ @@ -161,9 +161,9 @@ void* extal_GetProcAddress(const char* function); void extal_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions); /* Platform dependent functions */ -void *NativeGetFunctionPointer(const char *function); -void tryLoadLibrary(JNIEnv *env, jstring path); -void UnLoadOpenAL(); +void *extal_NativeGetFunctionPointer(const char *function); +void extal_LoadLibrary(JNIEnv *env, jstring path); +void extal_UnloadLibrary(); #ifdef __cplusplus } diff --git a/src/native/common/extcl.c b/src/native/common/extcl.c new file mode 100644 index 00000000..4ecf73b9 --- /dev/null +++ b/src/native/common/extcl.c @@ -0,0 +1,67 @@ +/* + * 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 + * 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. + */ + +#include +#include "extcl.h" + +typedef CL_API_ENTRY void * (CL_API_CALL *clGetExtensionFunctionAddressPROC) (const char * func_name); +static clGetExtensionFunctionAddressPROC clGetExtensionFunctionAddress; + +/** + * Retrieves a pointer to the named function + * + * @param function Name of function + * @return pointer to named function, or NULL if not found + */ +void* extcl_GetProcAddress(const char * function) { + void *p = NULL; + + if ( clGetExtensionFunctionAddress == NULL ) + clGetExtensionFunctionAddress = extcl_NativeGetFunctionPointer("clGetExtensionFunctionAddress"); + + p = clGetExtensionFunctionAddress(function); + if ( p == NULL ) + p = extcl_NativeGetFunctionPointer(function); + + return p; +} + +void extcl_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions) { + ext_InitializeClass(env, clazz, &extcl_GetProcAddress, num_functions, functions); +} + +int extcl_CalculateImageSize(const size_t *region, size_t row_pitch, size_t slice_pitch) { + if ( slice_pitch == 0 ) + return region[1] * row_pitch; + else + return region[2] * slice_pitch; +} diff --git a/src/native/common/extcl.h b/src/native/common/extcl.h new file mode 100644 index 00000000..df1aeffa --- /dev/null +++ b/src/native/common/extcl.h @@ -0,0 +1,87 @@ +/* + * 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 + * 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. + */ + +#ifndef __EXTCL_H__ +#define __EXTCL_H__ + +#include + +#ifdef __APPLE__ + #include +#else + #include +#endif + +#include "common_tools.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#include "extgl_types.h" +#include "extcl_types.h" + +// -----------------[ OpenGL-dependent typedefs ]----------------- +typedef GLsync cl_GLsync; + +// -----------------[ Callback function typedefs ]----------------- + +// TODO: This is a bug in current CL implementations (AMD's only?), remove when fixed. (used for cl_native_kernel_func) +#if defined(_WIN32) + #define CL_USER_FUNC_CALLBACK __cdecl +#else + #define CL_USER_FUNC_CALLBACK CL_CALLBACK +#endif + +typedef void (CL_CALLBACK * cl_create_context_callback)(const char *errinfo, const void *private_info, size_t cb, void *user_data); +typedef void (CL_CALLBACK * cl_mem_object_destructor_callback)(cl_mem memobj, void *user_data); +typedef void (CL_CALLBACK * cl_build_program_callback)(cl_program program, void *user_data); +typedef void (CL_CALLBACK * cl_event_callback)(cl_event event, cl_int event_command_exec_status, void *user_data); +typedef void (CL_USER_FUNC_CALLBACK * cl_native_kernel_func)(void *args); + +// -----------------[ Cross-platform functions ]----------------- + +void* extcl_GetProcAddress(const char* function); +void extcl_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions); +int extcl_CalculateImageSize(const size_t *region, size_t row_pitch, size_t slice_pitch); + +// -----------------[ Platform dependent functions ]----------------- + +void *extcl_NativeGetFunctionPointer(const char *function); +void extcl_LoadLibrary(JNIEnv *env, jstring path); +void extcl_UnloadLibrary(); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/native/common/extcl_types.h b/src/native/common/extcl_types.h new file mode 100644 index 00000000..f3b7220a --- /dev/null +++ b/src/native/common/extcl_types.h @@ -0,0 +1,74 @@ +// -----------------[ Core typedefs ]----------------- + +typedef struct _cl_platform_id * cl_platform_id; +typedef struct _cl_device_id * cl_device_id; +typedef struct _cl_context * cl_context; +typedef struct _cl_command_queue * cl_command_queue; +typedef struct _cl_mem * cl_mem; +typedef struct _cl_program * cl_program; +typedef struct _cl_kernel * cl_kernel; +typedef struct _cl_event * cl_event; +typedef struct _cl_sampler * cl_sampler; + +typedef cl_uint cl_bool; /* WARNING! Unlike cl_ types in cl_platform.h, cl_bool is not guaranteed to be the same size as the bool in kernels. */ +typedef cl_ulong cl_bitfield; +typedef cl_bitfield cl_device_type; +typedef cl_uint cl_platform_info; +typedef cl_uint cl_device_info; +typedef cl_bitfield cl_device_fp_config; +typedef cl_uint cl_device_mem_cache_type; +typedef cl_uint cl_device_local_mem_type; +typedef cl_bitfield cl_device_exec_capabilities; +typedef cl_bitfield cl_command_queue_properties; + +typedef intptr_t cl_context_properties; +typedef cl_uint cl_context_info; +typedef cl_uint cl_command_queue_info; +typedef cl_uint cl_channel_order; +typedef cl_uint cl_channel_type; +typedef cl_bitfield cl_mem_flags; +typedef cl_uint cl_mem_object_type; +typedef cl_uint cl_mem_info; +typedef cl_uint cl_image_info; +typedef cl_uint cl_buffer_create_type; +typedef cl_uint cl_addressing_mode; +typedef cl_uint cl_filter_mode; +typedef cl_uint cl_sampler_info; +typedef cl_bitfield cl_map_flags; +typedef cl_uint cl_program_info; +typedef cl_uint cl_program_build_info; +typedef cl_int cl_build_status; +typedef cl_uint cl_kernel_info; +typedef cl_uint cl_kernel_work_group_info; +typedef cl_uint cl_event_info; +typedef cl_uint cl_command_type; +typedef cl_uint cl_profiling_info; + +typedef struct _cl_image_format { + cl_channel_order image_channel_order; + cl_channel_type image_channel_data_type; +} cl_image_format; + +typedef struct _cl_buffer_region { + size_t origin; + size_t size; +} cl_buffer_region; + +// cl_gl.h +typedef cl_uint cl_gl_platform_info; +typedef cl_uint cl_gl_context_info; +typedef cl_uint cl_gl_object_type; +typedef cl_uint cl_gl_texture_info; + +// -----------------[ Extension typedefs ]----------------- + +// EXT_device_fission +typedef cl_bitfield cl_device_partition_property_ext; +// EXT_migrate_memobject +typedef cl_bitfield cl_mem_migration_flags_ext; + +// -----------------[ Convenience typedefs ]----------------- + +typedef void cl_void; +//typedef char cl_char; +//typedef unsigned char cl_uchar; diff --git a/src/native/common/extgl.h b/src/native/common/extgl.h index 2f20ba47..c2b242a6 100644 --- a/src/native/common/extgl.h +++ b/src/native/common/extgl.h @@ -70,68 +70,24 @@ THE POSSIBILITY OF SUCH DAMAGE. #include #include +#ifdef __APPLE__ + #include +#else + #include +#endif + #include "common_tools.h" #if defined(_WIN32) || defined(_WIN64) - #include // fix APIENTRY macro redefinition - # define int64_t __int64 - # define uint64_t unsigned __int64 + #include // fix APIENTRY macro redefinition #endif #ifndef APIENTRY -#define APIENTRY + #define APIENTRY #endif -#ifdef _MACOSX - typedef unsigned long GLenum; - typedef unsigned char GLboolean; - typedef unsigned long GLbitfield; - typedef signed char GLbyte; - typedef short GLshort; - typedef long GLint; - typedef long GLsizei; - typedef unsigned char GLubyte; - typedef unsigned short GLushort; - typedef unsigned long GLuint; - typedef float GLfloat; - typedef float GLclampf; - typedef double GLdouble; - typedef double GLclampd; - typedef void GLvoid; -#else - typedef unsigned int GLenum; - typedef unsigned char GLboolean; - typedef unsigned int GLbitfield; - typedef void GLvoid; - typedef signed char GLbyte; /* 1-byte signed */ - typedef short GLshort; /* 2-byte signed */ - typedef int GLint; /* 4-byte signed */ - typedef unsigned char GLubyte; /* 1-byte unsigned */ - typedef unsigned short GLushort; /* 2-byte unsigned */ - typedef unsigned int GLuint; /* 4-byte unsigned */ - typedef int GLsizei; /* 4-byte signed */ - typedef float GLfloat; /* single precision float */ - typedef float GLclampf; /* single precision float in [0,1] */ - typedef double GLdouble; /* double precision float */ - typedef double GLclampd; /* double precision float in [0,1] */ -#endif - -typedef char GLchar; /* native character */ - -typedef ptrdiff_t GLintptr; -typedef ptrdiff_t GLsizeiptr; -typedef ptrdiff_t GLintptrARB; -typedef ptrdiff_t GLsizeiptrARB; -typedef char GLcharARB; /* native character */ -typedef unsigned int GLhandleARB; /* shader object handle */ -typedef unsigned short GLhalfARB; -typedef unsigned short GLhalfNV; -typedef unsigned short GLhalf; -typedef int64_t GLint64EXT; -typedef uint64_t GLuint64EXT; -typedef int64_t GLint64; -typedef uint64_t GLuint64; -typedef struct __GLsync *GLsync; +#include "extcl_types.h" +#include "extgl_types.h" /* AMD_debug_output callback function pointer. */ typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam); @@ -139,8 +95,6 @@ typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id, GLenum category, GLenum sever /* ARB_debug_output callback function pointer. */ typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam); -/* helper stuff */ - /* initializes everything, call this right after the rc is created. the function returns true if successful */ extern bool extgl_Open(JNIEnv *env); extern void extgl_Close(void); diff --git a/src/native/common/extgl_types.h b/src/native/common/extgl_types.h new file mode 100644 index 00000000..c8d92dc0 --- /dev/null +++ b/src/native/common/extgl_types.h @@ -0,0 +1,55 @@ +#if defined(_WIN32) || defined(_WIN64) + #define int64_t __int64 + #define uint64_t unsigned __int64 +#endif + +#ifdef _MACOSX + typedef unsigned long GLenum; + typedef unsigned char GLboolean; + typedef unsigned long GLbitfield; + typedef signed char GLbyte; + typedef short GLshort; + typedef long GLint; + typedef long GLsizei; + typedef unsigned char GLubyte; + typedef unsigned short GLushort; + typedef unsigned long GLuint; + typedef float GLfloat; + typedef float GLclampf; + typedef double GLdouble; + typedef double GLclampd; + typedef void GLvoid; +#else + typedef unsigned int GLenum; + typedef unsigned char GLboolean; + typedef unsigned int GLbitfield; + typedef void GLvoid; + typedef signed char GLbyte; /* 1-byte signed */ + typedef short GLshort; /* 2-byte signed */ + typedef int GLint; /* 4-byte signed */ + typedef unsigned char GLubyte; /* 1-byte unsigned */ + typedef unsigned short GLushort; /* 2-byte unsigned */ + typedef unsigned int GLuint; /* 4-byte unsigned */ + typedef int GLsizei; /* 4-byte signed */ + typedef float GLfloat; /* single precision float */ + typedef float GLclampf; /* single precision float in [0,1] */ + typedef double GLdouble; /* double precision float */ + typedef double GLclampd; /* double precision float in [0,1] */ +#endif + +typedef char GLchar; /* native character */ + +typedef ptrdiff_t GLintptr; +typedef ptrdiff_t GLsizeiptr; +typedef ptrdiff_t GLintptrARB; +typedef ptrdiff_t GLsizeiptrARB; +typedef char GLcharARB; /* native character */ +typedef unsigned int GLhandleARB; /* shader object handle */ +typedef unsigned short GLhalfARB; +typedef unsigned short GLhalfNV; +typedef unsigned short GLhalf; +typedef int64_t GLint64EXT; +typedef uint64_t GLuint64EXT; +typedef int64_t GLint64; +typedef uint64_t GLuint64; +typedef struct __GLsync * GLsync; \ No newline at end of file diff --git a/src/native/common/opencl.h b/src/native/common/opencl.h new file mode 100644 index 00000000..901088d8 --- /dev/null +++ b/src/native/common/opencl.h @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2008-2010 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and/or associated documentation files (the + * "Materials"), to deal in the Materials without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Materials, and to + * permit persons to whom the Materials are furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + ******************************************************************************/ + +/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */ + +#ifndef __OPENCL_H +#define __OPENCL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __APPLE__ + +#include +#include +#include +#include + +#else + +#include +#include +#include +#include + +#endif + +#include "common_tools.h" + +#ifdef __cplusplus +} +#endif + +#endif /* __OPENCL_H */ + diff --git a/src/native/common/org_lwjgl_openal_AL.c b/src/native/common/org_lwjgl_openal_AL.c index 20b3243e..24c6520e 100644 --- a/src/native/common/org_lwjgl_openal_AL.c +++ b/src/native/common/org_lwjgl_openal_AL.c @@ -1,45 +1,45 @@ -/* +/* * 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. */ - + #include #include "org_lwjgl_openal_AL.h" #include "extal.h" JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL_nCreate(JNIEnv *env, jclass clazz, jstring oalPath) { - tryLoadLibrary(env, oalPath); + extal_LoadLibrary(env, oalPath); } JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL_nDestroy(JNIEnv *env, jclass clazz) { - UnLoadOpenAL(); + extal_UnloadLibrary(); } JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL_resetNativeStubs(JNIEnv *env, jclass clazz, jclass al_class) { diff --git a/src/native/common/org_lwjgl_opencl_CL.c b/src/native/common/org_lwjgl_opencl_CL.c new file mode 100644 index 00000000..04d22793 --- /dev/null +++ b/src/native/common/org_lwjgl_opencl_CL.c @@ -0,0 +1,56 @@ +/* + * 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 + * 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. + */ + +#include +#include "org_lwjgl_opencl_CL.h" +#include "extcl.h" + +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 void JNICALL Java_org_lwjgl_opencl_CL_nCreate(JNIEnv *env, jclass clazz, jstring oclPath) { + extcl_LoadLibrary(env, oclPath); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opencl_CL_nDestroy(JNIEnv *env, jclass clazz) { + extcl_UnloadLibrary(); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opencl_CL_resetNativeStubs(JNIEnv *env, jclass clazz, jclass cl_class) { + (*env)->UnregisterNatives(env, cl_class); +} diff --git a/src/native/common/org_lwjgl_opencl_CL.h b/src/native/common/org_lwjgl_opencl_CL.h new file mode 100644 index 00000000..6ba4c5c7 --- /dev/null +++ b/src/native/common/org_lwjgl_opencl_CL.h @@ -0,0 +1,54 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_lwjgl_opencl_CL */ + +#ifndef _Included_org_lwjgl_opencl_CL +#define _Included_org_lwjgl_opencl_CL +#ifdef __cplusplus +extern "C" { +#endif +/* Inaccessible static: created */ +/* + * Class: org_lwjgl_opencl_CL + * Method: nCreate + * Signature: (Ljava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_opencl_CL_nCreate + (JNIEnv *, jclass, jstring); + +/* + * Class: org_lwjgl_opencl_CL + * Method: nCreateDefault + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_opencl_CL_nCreateDefault + (JNIEnv *, jclass); + +/* + * Class: org_lwjgl_opencl_CL + * Method: nDestroy + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_opencl_CL_nDestroy + (JNIEnv *, jclass); + +/* + * Class: org_lwjgl_opencl_CL + * Method: getFunctionAddress + * Signature: (Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CL_getFunctionAddress + (JNIEnv *, jclass, jstring); + +/* + * Class: org_lwjgl_opencl_CL + * Method: resetNativeStubs + * Signature: (Ljava/lang/Class;)V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_opencl_CL_resetNativeStubs + (JNIEnv *, jclass, jclass); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/native/common/org_lwjgl_opencl_CallbackUtil.c b/src/native/common/org_lwjgl_opencl_CallbackUtil.c new file mode 100644 index 00000000..aa2919ef --- /dev/null +++ b/src/native/common/org_lwjgl_opencl_CallbackUtil.c @@ -0,0 +1,229 @@ +/* + * 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 + * 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. + */ + +/** + * JNI implementation of the AMD_debug_output function callback. + * + * @author Spasi + */ + +#include +#include "common_tools.h" +#include "extcl.h" +#include "org_lwjgl_opencl_CallbackUtil.h" + +static jmethodID contextCallbackJ; +static jmethodID memObjectDestructorCallbackJ; +static jmethodID buildProgramCallbackJ; +static jmethodID nativeKernelCallbackJ; +static jmethodID eventCallbackJ; + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_ncreateGlobalRef(JNIEnv *env, jclass clazz, jobject obj) { + return (intptr_t)(*env)->NewGlobalRef(env, obj); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opencl_CallbackUtil_deleteGlobalRef(JNIEnv *env, jclass clazz, jlong globalRef) { + (*env)->DeleteGlobalRef(env, (jobject)(intptr_t)globalRef); +} + +// ----------------- [ CONTEXT CALLBACK ] ----------------- + +static void CL_CALLBACK contextCallback(const char *errinfo, const void *private_info, size_t cb, void *user_data) { + JNIEnv *env = attachCurrentThread(); + jobject private_info_buffer = NULL; + + if ( env != NULL && !(*env)->ExceptionOccurred(env) && contextCallbackJ != NULL ) { + if ( private_info != NULL ) + private_info_buffer = NewReadOnlyDirectByteBuffer(env, private_info, cb); + + (*env)->CallVoidMethod(env, (jobject)user_data, contextCallbackJ, + NewStringNativeWithLength(env, errinfo, strlen(errinfo)), + private_info_buffer + ); + } + + detachCurrentThread(); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getContextCallback(JNIEnv *env, jclass clazz) { + // Cache the callback methodID + jclass callbackClass; + if ( contextCallbackJ == NULL ) { + callbackClass = (*env)->FindClass(env, "org/lwjgl/opencl/CLContextCallback"); + if ( callbackClass != NULL ) + contextCallbackJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(Ljava/lang/String;Ljava/nio/ByteBuffer;)V"); + } + + return (jlong)(intptr_t)&contextCallback; +} + +// ----------------- [ MEM OBJECT DESTRUCTOR CALLBACK ] ----------------- + +static void CL_CALLBACK memObjectDestructorCallback(cl_mem memobj, void *user_data) { + JNIEnv *env = attachCurrentThread(); + + if ( env != NULL && !(*env)->ExceptionOccurred(env) && memObjectDestructorCallbackJ != NULL ) { + (*env)->CallVoidMethod(env, (jobject)user_data, memObjectDestructorCallbackJ, + (jlong)(intptr_t)memobj + ); + (*env)->DeleteGlobalRef(env, (jobject)user_data); + } + + detachCurrentThread(); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getMemObjectDestructorCallback(JNIEnv *env, jclass clazz) { + // Cache the callback methodID + jclass callbackClass; + if ( memObjectDestructorCallbackJ == NULL ) { + callbackClass = (*env)->FindClass(env, "org/lwjgl/opencl/CLMemObjectDestructorCallback"); + if ( callbackClass != NULL ) + memObjectDestructorCallbackJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(J)V"); + } + + return (jlong)(intptr_t)&memObjectDestructorCallback; +} + +// ----------------- [ MEM OBJECT DESTRUCTOR CALLBACK ] ----------------- + +static void CL_CALLBACK buildProgramCallback(cl_program program, void *user_data) { + JNIEnv *env = attachCurrentThread(); + + if ( env != NULL && !(*env)->ExceptionOccurred(env) && buildProgramCallbackJ != NULL ) { + (*env)->CallVoidMethod(env, (jobject)user_data, buildProgramCallbackJ, + (jlong)(intptr_t)program + ); + (*env)->DeleteGlobalRef(env, (jobject)user_data); + } + + detachCurrentThread(); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getBuildProgramCallback(JNIEnv *env, jclass clazz) { + // Cache the callback methodID + jclass callbackClass; + if ( buildProgramCallbackJ == NULL ) { + callbackClass = (*env)->FindClass(env, "org/lwjgl/opencl/CLBuildProgramCallback"); + if ( callbackClass != NULL ) + buildProgramCallbackJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(J)V"); + } + + return (jlong)(intptr_t)&buildProgramCallback; +} + +// ----------------- [ NATIVE KERNEL CALLBACK ] ----------------- + +static void CL_USER_FUNC_CALLBACK nativeKernelCallback(void *args) { + JNIEnv *env = attachCurrentThread(); + jobject user_func = (jobject)*(intptr_t *)args; + jint num_mem_objects = *(jint *)((char *)args + 8); + jobjectArray memobjs = NULL; + jobject buffer; + jint i; + + if ( env != NULL && !(*env)->ExceptionOccurred(env) && nativeKernelCallbackJ != NULL ) { + if ( num_mem_objects > 0 ) { + memobjs = (*env)->NewObjectArray(env, num_mem_objects, (*env)->FindClass(env, "java/nio/ByteBuffer"), NULL); + for ( i = 0; i < num_mem_objects; i++ ) { + buffer = (*env)->NewDirectByteBuffer(env, + // Pointer to cl_mem buffer + (void *)((char *)args + (12 + 4 + (i * (4 + sizeof(size_t))))), + // cl_mem buffer size + *((jint *)((char *)args + (12 + (i * (4 + sizeof(size_t)))))) + ); + (*env)->SetObjectArrayElement(env, memobjs, i, buffer); + } + } + + (*env)->CallVoidMethod(env, user_func, nativeKernelCallbackJ, memobjs); + + if ( num_mem_objects > 0 ) + (*env)->DeleteLocalRef(env, memobjs); + (*env)->DeleteGlobalRef(env, user_func); + } + + detachCurrentThread(); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getNativeKernelCallback(JNIEnv *env, jclass clazz) { + // Cache the callback methodID + jclass callbackClass; + if ( nativeKernelCallbackJ == NULL ) { + callbackClass = (*env)->FindClass(env, "org/lwjgl/opencl/CLNativeKernel"); + if ( callbackClass != NULL ) + nativeKernelCallbackJ = (*env)->GetMethodID(env, callbackClass, "execute", "([Ljava/nio/ByteBuffer;)V"); + } + + return (jlong)(intptr_t)&nativeKernelCallback; +} + +// ----------------- [ EVENT CALLBACK ] ----------------- + +static void CL_CALLBACK eventCallback(cl_event event, cl_int event_command_exec_status, void *user_data) { + JNIEnv *env = attachCurrentThread(); + + if ( env != NULL && !(*env)->ExceptionOccurred(env) && eventCallbackJ != NULL ) { + (*env)->CallVoidMethod(env, (jobject)user_data, eventCallbackJ, + (jlong)(intptr_t)event, + event_command_exec_status + ); + (*env)->DeleteGlobalRef(env, (jobject)user_data); + } + + detachCurrentThread(); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getEventCallback(JNIEnv *env, jclass clazz) { + // Cache the callback methodID + jclass callbackClass; + if ( eventCallbackJ == NULL ) { + callbackClass = (*env)->FindClass(env, "org/lwjgl/opencl/CLEventCallback"); + if ( callbackClass != NULL ) + eventCallbackJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(JI)V"); + } + + return (jlong)(intptr_t)&eventCallback; +} + +// ----------------- [ APPLE_ContextLoggingFunctions CALLBACKS ] ----------------- + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getLogMessageToSystemLogAPPLE(JNIEnv *env, jclass clazz) { + return (jlong)(intptr_t)extcl_GetProcAddress("clLogMessagesToSystemLogAPPLE"); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getLogMessageToStdoutAPPLE(JNIEnv *env, jclass clazz) { + return (jlong)(intptr_t)extcl_GetProcAddress("getLogMessageToStdoutAPPLE"); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getLogMessageToStderrAPPLE(JNIEnv *env, jclass clazz) { + return (jlong)(intptr_t)extcl_GetProcAddress("getLogMessageToStderrAPPLE"); +} diff --git a/src/native/common/org_lwjgl_opencl_CallbackUtil.h b/src/native/common/org_lwjgl_opencl_CallbackUtil.h new file mode 100644 index 00000000..9877a910 --- /dev/null +++ b/src/native/common/org_lwjgl_opencl_CallbackUtil.h @@ -0,0 +1,94 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_lwjgl_opencl_CallbackUtil */ + +#ifndef _Included_org_lwjgl_opencl_CallbackUtil +#define _Included_org_lwjgl_opencl_CallbackUtil +#ifdef __cplusplus +extern "C" { +#endif +/* Inaccessible static: contextUserData */ +/* + * Class: org_lwjgl_opencl_CallbackUtil + * Method: ncreateGlobalRef + * Signature: (Ljava/lang/Object;)J + */ +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_ncreateGlobalRef + (JNIEnv *, jclass, jobject); + +/* + * Class: org_lwjgl_opencl_CallbackUtil + * Method: deleteGlobalRef + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_opencl_CallbackUtil_deleteGlobalRef + (JNIEnv *, jclass, jlong); + +/* + * Class: org_lwjgl_opencl_CallbackUtil + * Method: getContextCallback + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getContextCallback + (JNIEnv *, jclass); + +/* + * Class: org_lwjgl_opencl_CallbackUtil + * Method: getMemObjectDestructorCallback + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getMemObjectDestructorCallback + (JNIEnv *, jclass); + +/* + * Class: org_lwjgl_opencl_CallbackUtil + * Method: getBuildProgramCallback + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getBuildProgramCallback + (JNIEnv *, jclass); + +/* + * Class: org_lwjgl_opencl_CallbackUtil + * Method: getNativeKernelCallback + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getNativeKernelCallback + (JNIEnv *, jclass); + +/* + * Class: org_lwjgl_opencl_CallbackUtil + * Method: getEventCallback + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getEventCallback + (JNIEnv *, jclass); + +/* + * Class: org_lwjgl_opencl_CallbackUtil + * Method: getLogMessageToSystemLogAPPLE + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getLogMessageToSystemLogAPPLE + (JNIEnv *, jclass); + +/* + * Class: org_lwjgl_opencl_CallbackUtil + * Method: getLogMessageToStdoutAPPLE + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getLogMessageToStdoutAPPLE + (JNIEnv *, jclass); + +/* + * Class: org_lwjgl_opencl_CallbackUtil + * Method: getLogMessageToStderrAPPLE + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getLogMessageToStderrAPPLE + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/native/common/org_lwjgl_opengl_AMDDebugOutputCallback.c b/src/native/common/org_lwjgl_opengl_AMDDebugOutputCallback.c deleted file mode 100644 index ee13e4cd..00000000 --- a/src/native/common/org_lwjgl_opengl_AMDDebugOutputCallback.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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 - * 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. - */ - -/** - * JNI implementation of the AMD_debug_output function callback. - * - * @author Spasi - */ - -#include -#include "common_tools.h" -#include "extgl.h" -#include "org_lwjgl_opengl_AMDDebugOutputCallback.h" - -static jclass debugOutputCallbackClassAMD; -static jmethodID debugOutputCallbackMethodAMD; - -static void APIENTRY debugOutputCallbackAMD(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam) { - /* - jclass callback_class; - jmethodID callback_method; - JNIEnv *env = getThreadEnv(); - if (env != NULL && !(*env)->ExceptionOccurred(env)) { - callback_class = (*env)->FindClass(env, "org/lwjgl/opengl/AMDDebugOutputUtil"); - if ( callback_class != NULL ) { - callback_method = (*env)->GetStaticMethodID(env, callback_class, "messageCallback", "(IIILjava/lang/String;Ljava/nio/ByteBuffer;)V"); - if ( callback_method != NULL ) { - (*env)->CallStaticVoidMethod(env, callback_class, callback_method, - (jint)id, - (jint)category, - (jint)severity, - NewStringNativeWithLength(env, message, length), - NULL - ); - } - } - } - */ - - JNIEnv *env = getThreadEnv(); - if ( env != NULL && !(*env)->ExceptionOccurred(env) && debugOutputCallbackMethodAMD != NULL ) { - (*env)->CallStaticVoidMethod(env, debugOutputCallbackClassAMD, debugOutputCallbackMethodAMD, - (jint)id, - (jint)category, - (jint)severity, - NewStringNativeWithLength(env, message, length), - NULL // Ignoring user param, pointless for our implementation - ); - } -} - -JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_AMDDebugOutputCallback_getFunctionPointer(JNIEnv *env, jclass clazz) { - // Cache the callback class and methodID - debugOutputCallbackClassAMD = (*env)->FindClass(env, "org/lwjgl/opengl/AMDDebugOutputUtil"); - if ( debugOutputCallbackClassAMD != NULL ) - debugOutputCallbackMethodAMD = (*env)->GetStaticMethodID(env, debugOutputCallbackClassAMD, "messageCallback", "(IIILjava/lang/String;Ljava/nio/ByteBuffer;)V"); - - return (jlong)(intptr_t)&debugOutputCallbackAMD; -} diff --git a/src/native/common/org_lwjgl_opengl_ARBDebugOutputCallback.c b/src/native/common/org_lwjgl_opengl_ARBDebugOutputCallback.c deleted file mode 100644 index 365739db..00000000 --- a/src/native/common/org_lwjgl_opengl_ARBDebugOutputCallback.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 - * 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. - */ - -/** - * JNI implementation of the AMD_debug_output function callback. - * - * @author Spasi - */ - -#include -#include "common_tools.h" -#include "extgl.h" -#include "org_lwjgl_opengl_ARBDebugOutputCallback.h" - -static jclass debugOutputCallbackClassARB; -static jmethodID debugOutputCallbackMethodARB; - -static void APIENTRY debugOutputCallbackARB(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam) { - JNIEnv *env = getThreadEnv(); - if ( env != NULL && !(*env)->ExceptionOccurred(env) && debugOutputCallbackMethodARB != NULL ) { - (*env)->CallStaticVoidMethod(env, debugOutputCallbackClassARB, debugOutputCallbackMethodARB, - (jint)source, - (jint)type, - (jint)id, - (jint)severity, - NewStringNativeWithLength(env, message, length), - NULL // Ignoring user param, pointless for our implementation - ); - } -} - -JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_ARBDebugOutputCallback_getFunctionPointer(JNIEnv *env, jclass clazz) { - // Cache the callback class and methodID - debugOutputCallbackClassARB = (*env)->FindClass(env, "org/lwjgl/opengl/ARBDebugOutputUtil"); - if ( debugOutputCallbackClassARB != NULL ) - debugOutputCallbackMethodARB = (*env)->GetStaticMethodID(env, debugOutputCallbackClassARB, "messageCallback", "(IIIILjava/lang/String;Ljava/nio/ByteBuffer;)V"); - - return (jlong)(intptr_t)&debugOutputCallbackARB; -} diff --git a/src/native/common/org_lwjgl_opengl_CallbackUtil.c b/src/native/common/org_lwjgl_opengl_CallbackUtil.c new file mode 100644 index 00000000..4412d02b --- /dev/null +++ b/src/native/common/org_lwjgl_opengl_CallbackUtil.c @@ -0,0 +1,112 @@ +/* + * 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 + * 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. + */ + +/** + * JNI implementation of the AMD_debug_output function callback. + * + * @author Spasi + */ + +#include +#include "common_tools.h" +#include "extgl.h" +#include "org_lwjgl_opengl_CallbackUtil.h" + +static jmethodID debugOutputCallbackARBJ; +static jmethodID debugOutputCallbackAMDJ; + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_ncreateGlobalRef(JNIEnv *env, jclass clazz, jobject obj) { + return (jlong)(*env)->NewGlobalRef(env, obj); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_CallbackUtil_deleteGlobalRef(JNIEnv *env, jclass clazz, jlong globalRef) { + (*env)->DeleteGlobalRef(env, (jobject)globalRef); +} + +// ----------------- [ ARB_debug_output ] ----------------- + +static void APIENTRY debugOutputCallbackARB(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam) { + JNIEnv *env = attachCurrentThread(); + + if ( env != NULL && !(*env)->ExceptionOccurred(env) && debugOutputCallbackARBJ != NULL ) { + (*env)->CallVoidMethod(env, (jobject)userParam, debugOutputCallbackARBJ, + (jint)source, + (jint)type, + (jint)id, + (jint)severity, + NewStringNativeWithLength(env, message, length) + ); + } + + detachCurrentThread(); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_getDebugOutputCallbackARB(JNIEnv *env, jclass clazz) { + // Cache the callback methodID + jclass callbackClass; + if ( debugOutputCallbackARBJ == NULL ) { + callbackClass = (*env)->FindClass(env, "org/lwjgl/opengl/ARBDebugOutputCallback$Handler"); + if ( callbackClass != NULL ) + debugOutputCallbackARBJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(IIIILjava/lang/String;)V"); + } + + return (jlong)(intptr_t)&debugOutputCallbackARB; +} + +// ----------------- [ AMD_debug_output ] ----------------- + +static void APIENTRY debugOutputCallbackAMD(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam) { + JNIEnv *env = attachCurrentThread(); + + if ( env != NULL && !(*env)->ExceptionOccurred(env) && debugOutputCallbackAMDJ != NULL ) { + (*env)->CallVoidMethod(env, (jobject)userParam, debugOutputCallbackAMDJ, + (jint)id, + (jint)category, + (jint)severity, + NewStringNativeWithLength(env, message, length) + ); + } + + detachCurrentThread(); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_getDebugOutputCallbackAMD(JNIEnv *env, jclass clazz) { + // Cache the callback methodID + jclass callbackClass; + if ( debugOutputCallbackAMDJ == NULL ) { + callbackClass = (*env)->FindClass(env, "org/lwjgl/opengl/AMDDebugOutputCallback$Handler"); + if ( callbackClass != NULL ) + debugOutputCallbackAMDJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(IIILjava/lang/String;)V"); + } + + return (jlong)(intptr_t)&debugOutputCallbackAMD; +} \ No newline at end of file diff --git a/src/native/common/org_lwjgl_opengl_CallbackUtil.h b/src/native/common/org_lwjgl_opengl_CallbackUtil.h new file mode 100644 index 00000000..44928bb1 --- /dev/null +++ b/src/native/common/org_lwjgl_opengl_CallbackUtil.h @@ -0,0 +1,47 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_lwjgl_opengl_CallbackUtil */ + +#ifndef _Included_org_lwjgl_opengl_CallbackUtil +#define _Included_org_lwjgl_opengl_CallbackUtil +#ifdef __cplusplus +extern "C" { +#endif +/* Inaccessible static: contextUserParamsARB */ +/* Inaccessible static: contextUserParamsAMD */ +/* + * Class: org_lwjgl_opengl_CallbackUtil + * Method: ncreateGlobalRef + * Signature: (Ljava/lang/Object;)J + */ +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_ncreateGlobalRef + (JNIEnv *, jclass, jobject); + +/* + * Class: org_lwjgl_opengl_CallbackUtil + * Method: deleteGlobalRef + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_CallbackUtil_deleteGlobalRef + (JNIEnv *, jclass, jlong); + +/* + * Class: org_lwjgl_opengl_CallbackUtil + * Method: getDebugOutputCallbackARB + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_getDebugOutputCallbackARB + (JNIEnv *, jclass); + +/* + * Class: org_lwjgl_opengl_CallbackUtil + * Method: getDebugOutputCallbackAMD + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_getDebugOutputCallbackAMD + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/native/linux/linux_al.c b/src/native/linux/linux_al.c index 1cc932cb..129f05ef 100644 --- a/src/native/linux/linux_al.c +++ b/src/native/linux/linux_al.c @@ -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. */ @@ -41,11 +41,11 @@ static void* handleOAL; -void *NativeGetFunctionPointer(const char *function) { +void *extal_NativeGetFunctionPointer(const char *function) { return dlsym(handleOAL, function); } -void tryLoadLibrary(JNIEnv *env, jstring path) { +void extal_LoadLibrary(JNIEnv *env, jstring path) { char *path_str = GetStringNativeChars(env, path); printfDebugJava(env, "Testing '%s'", path_str); handleOAL = dlopen(path_str, RTLD_LAZY); @@ -57,7 +57,7 @@ void tryLoadLibrary(JNIEnv *env, jstring path) { free(path_str); } -void UnLoadOpenAL() { +void extal_UnloadLibrary() { if (handleOAL != NULL) { dlclose(handleOAL); handleOAL = NULL; diff --git a/src/native/linux/linux_cl.c b/src/native/linux/linux_cl.c new file mode 100644 index 00000000..3fbd1942 --- /dev/null +++ b/src/native/linux/linux_cl.c @@ -0,0 +1,64 @@ +/* + * 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. + */ + +#include +#include +#include +#include "extcl.h" +#include "common_tools.h" + +#include + +static void* handleOCL; + +void *extcl_NativeGetFunctionPointer(const char *function) { + return dlsym(handleOCL, function); +} + +void extcl_LoadLibrary(JNIEnv *env, jstring path) { + char *path_str = GetStringNativeChars(env, path); + printfDebugJava(env, "Testing '%s'", path_str); + handleOCL = dlopen(path_str, RTLD_LAZY); + if (handleOCL != NULL) { + printfDebugJava(env, "Found OpenCL at '%s'", path_str); + } else { + throwException(env, "Could not load OpenCL library"); + } + free(path_str); +} + +void extcl_UnloadLibrary() { + if (handleOCL != NULL) { + dlclose(handleOCL); + handleOCL = NULL; + } +} diff --git a/src/native/linux/org_lwjgl_opengl_LinuxContextImplementation.c b/src/native/linux/org_lwjgl_opengl_LinuxContextImplementation.c index af71c59e..971c5140 100644 --- a/src/native/linux/org_lwjgl_opengl_LinuxContextImplementation.c +++ b/src/native/linux/org_lwjgl_opengl_LinuxContextImplementation.c @@ -106,6 +106,16 @@ static void createContextGLX(JNIEnv *env, X11PeerInfo *peer_info, X11Context *co context_info->context = context; } +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_getGLXContext(JNIEnv *env, jclass clazz, jobject context_handle) { + X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle); + return (intptr_t)context_info->context; +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_getDisplay(JNIEnv *env, jclass clazz, jobject peer_info_handle) { + X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); + return (intptr_t)peer_info->display; +} + JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nSetSwapInterval (JNIEnv *env, jclass clazz, jobject context_handle, jint value) { diff --git a/src/native/macosx/macosx_al.c b/src/native/macosx/macosx_al.c index 77318519..a99f999c 100644 --- a/src/native/macosx/macosx_al.c +++ b/src/native/macosx/macosx_al.c @@ -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. */ @@ -89,7 +89,7 @@ static CFBundleRef tryLoadFramework(JNIEnv *env) { return openal_bundle; } -void tryLoadLibrary(JNIEnv *env, jstring path) { +void extal_LoadLibrary(JNIEnv *env, jstring path) { const char *path_str = (*env)->GetStringUTFChars(env, path, NULL); printfDebugJava(env, "Testing '%s'", path_str); handleOAL = NSAddImage(path_str, NSADDIMAGE_OPTION_RETURN_ON_ERROR); @@ -104,7 +104,7 @@ void tryLoadLibrary(JNIEnv *env, jstring path) { /** * Unloads the OpenAL Library */ -void UnLoadOpenAL() { +void extal_UnloadLibrary() { if (openal_bundle != NULL) { CFRelease(openal_bundle); openal_bundle = NULL; diff --git a/src/native/macosx/macosx_cl.c b/src/native/macosx/macosx_cl.c new file mode 100644 index 00000000..85797d95 --- /dev/null +++ b/src/native/macosx/macosx_cl.c @@ -0,0 +1,114 @@ +/* + * 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 + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "extcl.h" +#include "common_tools.h" + +/** + * OpenCL library management + */ +static const struct mach_header* handleOCL = NULL; +static CFBundleRef opencl_bundle = NULL; + +void *NativeGetFunctionPointer(const char *function) { + void *address = NULL; + if (handleOCL != NULL) { + char *mac_symbol_name = (char *)malloc((strlen(function) + 2)*sizeof(char)); + if (mac_symbol_name == NULL) + return NULL; + mac_symbol_name[0] = '_'; + strcpy(&(mac_symbol_name[1]), function); + NSSymbol symbol = NSLookupSymbolInImage(handleOCL, mac_symbol_name, NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); + free(mac_symbol_name); + if (symbol != NULL) { + address = NSAddressOfSymbol(symbol); + } + } else if (opencl_bundle != NULL) { + CFStringRef cf_function = CFStringCreateWithCString(NULL, function, kCFStringEncodingUTF8); + address = CFBundleGetFunctionPointerForName(opencl_bundle, cf_function); + CFRelease(cf_function); + } + return address; +} + +static CFBundleRef tryLoadFramework(JNIEnv *env) { + CFStringRef framework_path = CFSTR("/System/Library/Frameworks/OpenCL.framework"); + if (framework_path == NULL) { + printfDebugJava(env, "Failed to allocate string"); + return NULL; + } + CFURLRef url = CFURLCreateWithFileSystemPath(NULL, framework_path, kCFURLPOSIXPathStyle, TRUE); + if (url == NULL) { + printfDebugJava(env, "Failed to allocate URL"); + return NULL; + } + CFBundleRef opencl_bundle = CFBundleCreate(NULL, url); + CFRelease(url); + return opencl_bundle; +} + +void extcl_LoadLibrary(JNIEnv *env, jstring path) { + const char *path_str = (*env)->GetStringUTFChars(env, path, NULL); + printfDebugJava(env, "Testing '%s'", path_str); + handleOCL = NSAddImage(path_str, NSADDIMAGE_OPTION_RETURN_ON_ERROR); + if (handleOCL != NULL) { + printfDebugJava(env, "Found OpenCL at '%s'", path_str); + } else { + throwException(env, "Could not load OpenCL library"); + } + (*env)->ReleaseStringUTFChars(env, path, path_str); +} + +/** + * Unloads the OpenCL Library + */ +void extcl_UnloadLibrary() { + if (opencl_bundle != NULL) { + CFRelease(opencl_bundle); + opencl_bundle = NULL; + } +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opencl_CL_nCreateDefault(JNIEnv *env, jclass clazz) { + opencl_bundle = tryLoadFramework(env); + if (opencl_bundle != NULL) + printfDebugJava(env, "Found OpenCL Bundle"); + else + throwException(env, "Could not load OpenCL framework"); +} diff --git a/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c b/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c index a13b3039..894caff2 100644 --- a/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c +++ b/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c @@ -54,13 +54,13 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nCr WindowsContext *context_info; HGLRC context; HGLRC shared_context = NULL; - + // -- We need to create a temporary context to detect the presence of WGL_ARB_create_context HDC saved_current_hdc; HGLRC saved_current_hglrc; WGLExtensions extensions; const int *attribList = attribs == NULL ? NULL : ((const int *)(*env)->GetDirectBufferAddress(env, attribs)); - + jobject context_handle = newJavaManagedByteBuffer(env, sizeof(WindowsContext)); if (context_handle == NULL) { throwException(env, "Could not create handle buffer"); @@ -120,6 +120,16 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nCr return context_handle; } +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_getHGLRC(JNIEnv *env, jclass clazz, jobject context_handle) { + WindowsContext *context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle); + return (intptr_t)context_info->context; +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_getHDC(JNIEnv *env, jclass clazz, jobject peer_info_handle) { + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + return (intptr_t)peer_info->drawable_hdc; +} + JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSwapBuffers (JNIEnv *env, jclass clazz, jobject peer_info_handle) { WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); diff --git a/src/native/windows/windows_al.c b/src/native/windows/windows_al.c index 1ce9171e..98b13723 100644 --- a/src/native/windows/windows_al.c +++ b/src/native/windows/windows_al.c @@ -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. */ @@ -47,11 +47,11 @@ /* Handle to OpenAL Library */ static HMODULE handleOAL; -void *NativeGetFunctionPointer(const char *function) { +void *extal_NativeGetFunctionPointer(const char *function) { return GetProcAddress(handleOAL, function); } -void tryLoadLibrary(JNIEnv *env, jstring path) { +void extal_LoadLibrary(JNIEnv *env, jstring path) { char *path_str = GetStringNativeChars(env, path); printfDebugJava(env, "Testing '%s'", path_str); handleOAL = LoadLibrary(path_str); @@ -66,6 +66,6 @@ void tryLoadLibrary(JNIEnv *env, jstring path) { /** * Unloads the OpenAL Library */ -void UnLoadOpenAL() { +void extal_UnloadLibrary() { FreeLibrary(handleOAL); } diff --git a/src/native/windows/windows_cl.c b/src/native/windows/windows_cl.c new file mode 100644 index 00000000..7b24fdb9 --- /dev/null +++ b/src/native/windows/windows_cl.c @@ -0,0 +1,73 @@ +/* + * 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 + * 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. + */ + +#include +#include +#include +#include +#include "extcl.h" +#include "common_tools.h" + +/** + * This file contains the CL extension assigning mechanism + * + * @author Spasi + */ + +/* Handle to OpenCL Library */ +static HMODULE handleOCL; + +void * extcl_NativeGetFunctionPointer(const char *func_name) { + return GetProcAddress(handleOCL, func_name); +} + +void extcl_LoadLibrary(JNIEnv *env, jstring path) { + char *path_str = GetStringNativeChars(env, path); + printfDebugJava(env, "Testing '%s'", path_str); + handleOCL = LoadLibrary(path_str); + if (handleOCL != NULL) { + printfDebugJava(env, "Found OpenCL at '%s'", path_str); + } else { + throwFormattedException(env, "Could not load OpenCL library (%d)", GetLastError()); + } + free(path_str); +} + +/** + * Unloads the OpenCL Library + */ +void extcl_UnloadLibrary() { + if ( handleOCL != NULL ) { + FreeLibrary(handleOCL); + handleOCL = NULL; + } +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/openal/AL10.java b/src/templates/org/lwjgl/openal/AL10.java index 32910ee5..a8358188 100644 --- a/src/templates/org/lwjgl/openal/AL10.java +++ b/src/templates/org/lwjgl/openal/AL10.java @@ -37,6 +37,7 @@ import java.nio.FloatBuffer; import java.nio.DoubleBuffer; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.openal.*; /** *
@@ -492,7 +493,7 @@ public interface AL10 { @StripPostfix("data") @ALvoid void alGetFloatv(@ALenum int pname, @OutParameter @Check("1") FloatBuffer data); - + /** * Like OpenGL, AL uses a simplified interface for querying global state. * diff --git a/src/templates/org/lwjgl/openal/AL11.java b/src/templates/org/lwjgl/openal/AL11.java index f484849c..1fb6b520 100644 --- a/src/templates/org/lwjgl/openal/AL11.java +++ b/src/templates/org/lwjgl/openal/AL11.java @@ -31,13 +31,13 @@ */ package org.lwjgl.openal; -import java.nio.Buffer; import java.nio.IntBuffer; import java.nio.FloatBuffer; -import java.nio.DoubleBuffer; -import org.lwjgl.openal.AL10; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.openal.ALenum; +import org.lwjgl.util.generator.openal.ALuint; +import org.lwjgl.util.generator.openal.ALvoid; /** *
@@ -52,33 +52,33 @@ public interface AL11 { /** Source buffer position information in seconds */ public static final int AL_SEC_OFFSET = 0x1024; - + /** Source buffer position information in samples */ public static final int AL_SAMPLE_OFFSET = 0x1025; - + /** Source buffer position information in bytes */ public static final int AL_BYTE_OFFSET = 0x1026; /** Type of source: Buffer has been attached using AL_BUFFER */ public static final int AL_STATIC = 0x1028; - + /** Type of source: if one or more Buffers have been attached using alSourceQueueBuffers */ public static final int AL_STREAMING = 0x1029; - + /** Type of source: when it has the NULL buffer attached */ public static final int AL_UNDETERMINED = 0x1030; /** @see AL10#AL_INVALID_OPERATION */ public static final int AL_ILLEGAL_COMMAND = 0xA004; - + /** Speed of Sound in units per second */ public static final int AL_SPEED_OF_SOUND = 0xC003; - + public static final int AL_LINEAR_DISTANCE = 0xD003; public static final int AL_LINEAR_DISTANCE_CLAMPED = 0xD004; public static final int AL_EXPONENT_DISTANCE = 0xD005; public static final int AL_EXPONENT_DISTANCE_CLAMPED = 0xD006; - + /** * Listener attributes are changed using the Listener group of commands. * @@ -89,7 +89,7 @@ public interface AL11 { */ @ALvoid void alListener3i(@ALenum int pname, int v1, int v2, int v3); - + /** * Listener state is maintained inside the AL implementation and can be queried in * full. @@ -101,7 +101,7 @@ public interface AL11 { @StripPostfix("intdata") @ALvoid void alGetListeneriv(@ALenum int pname, @OutParameter @Check("1") FloatBuffer intdata); - + /** * Specifies the position and other properties as taken into account during * sound processing. @@ -114,7 +114,7 @@ public interface AL11 { */ @ALvoid void alSource3i(@ALuint int source, @ALenum int pname, int v1, int v2, int v3); - + /** * Specifies the position and other properties as taken into account during * sound processing. @@ -127,7 +127,7 @@ public interface AL11 { @StripPostfix("value") @ALvoid void alSourceiv(@ALuint int source, @ALenum int pname, @Check("1") @Const IntBuffer value); - + /** * This function sets a floating point property of a buffer. * note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by @@ -138,8 +138,8 @@ public interface AL11 { * @param value value of property */ @ALvoid - void alBufferf(@ALuint int buffer, @ALenum int pname, float value); - + void alBufferf(@ALuint int buffer, @ALenum int pname, float value); + /** * This function sets a floating point property of a buffer. * note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by @@ -153,7 +153,7 @@ public interface AL11 { */ @ALvoid void alBuffer3f(@ALuint int buffer, @ALenum int pname, float v1, float v2, float v3); - + /** * This function sets a floating point property of a buffer. * note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by @@ -167,7 +167,7 @@ public interface AL11 { @StripPostfix("value") @ALvoid void alBufferfv(@ALuint int buffer, @ALenum int pname, @Check("1") @Const FloatBuffer value); - + /** * This function sets an integer property of a buffer. * note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by @@ -178,8 +178,8 @@ public interface AL11 { * @param value value of property */ @ALvoid - void alBufferi(@ALuint int buffer, @ALenum int pname, int value); - + void alBufferi(@ALuint int buffer, @ALenum int pname, int value); + /** * This function sets an integer property of a buffer. * note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by @@ -193,7 +193,7 @@ public interface AL11 { */ @ALvoid void alBuffer3i(@ALuint int buffer, @ALenum int pname, int v1, int v2, int v3); - + /** * This function sets an integer property of a buffer. * note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by @@ -207,22 +207,22 @@ public interface AL11 { @StripPostfix("value") @ALvoid void alBufferiv(@ALuint int buffer, @ALenum int pname, @Check("1") @Const IntBuffer value); - + /** * This function retrieves an integer property of a buffer. * note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by * this call, but this function may be used by OpenAL extensions. - * + * * @param buffer Buffer to get property from * @param pname name of property * @return int */ @ALvoid void alGetBufferi(@ALuint int buffer, @ALenum int pname, @Result int value); - + /** * This function retrieves an integer property of a buffer. - * + * * @param buffer Buffer to get property from * @param pname name of property */ @@ -235,7 +235,7 @@ public interface AL11 { * This function retrieves a floating point property of a buffer. * note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by * this call, but this function may be used by OpenAL extensions. - * + * * @param buffer Buffer to get property from * @param pname name of property * @return floating point property @@ -247,7 +247,7 @@ public interface AL11 { * This function retrieves a floating point property of a buffer. * note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by * this call, but this function may be used by OpenAL extensions. - * + * * @param buffer Buffer to get property from * @param pname name of property */ @@ -255,7 +255,7 @@ public interface AL11 { @StripPostfix("values") @ALvoid void alGetBufferfv(@ALuint int buffer, @ALenum int pname, @OutParameter @Check("1") FloatBuffer values); - + /** *

* AL_SPEED_OF_SOUND allows the application to change the reference (propagation) @@ -274,5 +274,5 @@ public interface AL11 { * @param value distance model to be set */ @ALvoid - void alSpeedOfSound(float value); + void alSpeedOfSound(float value); } diff --git a/src/templates/org/lwjgl/openal/EFX10.java b/src/templates/org/lwjgl/openal/EFX10.java index cb767002..40a69df8 100644 --- a/src/templates/org/lwjgl/openal/EFX10.java +++ b/src/templates/org/lwjgl/openal/EFX10.java @@ -34,19 +34,12 @@ package org.lwjgl.openal; import java.nio.FloatBuffer; import java.nio.IntBuffer; -import org.lwjgl.util.generator.ALenum; -import org.lwjgl.util.generator.ALsizei; -import org.lwjgl.util.generator.ALuint; -import org.lwjgl.util.generator.ALvoid; +import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.openal.ALenum; +import org.lwjgl.util.generator.openal.ALsizei; +import org.lwjgl.util.generator.openal.ALuint; +import org.lwjgl.util.generator.openal.ALvoid; import org.lwjgl.util.generator.Alternate; -import org.lwjgl.util.generator.AutoSize; -import org.lwjgl.util.generator.Check; -import org.lwjgl.util.generator.Const; -import org.lwjgl.util.generator.Constant; -import org.lwjgl.util.generator.Indirect; -import org.lwjgl.util.generator.OutParameter; -import org.lwjgl.util.generator.Result; -import org.lwjgl.util.generator.StripPostfix; /** * Implementation of the OpenAL extension ALC_EXT_EFX (version 1.0). Contains necessary fields, diff --git a/src/templates/org/lwjgl/opencl/AMD_device_attribute_query.java b/src/templates/org/lwjgl/opencl/AMD_device_attribute_query.java new file mode 100644 index 00000000..5c7f5a25 --- /dev/null +++ b/src/templates/org/lwjgl/opencl/AMD_device_attribute_query.java @@ -0,0 +1,45 @@ +/* + * 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.util.generator.opencl.CLDeviceExtension; + +@CLDeviceExtension +public interface AMD_device_attribute_query { + + /** + * Accepted as the <param_name> parameter of clGetDeviceInfo. Return the + * offset in nano-seconds between an event timestamp and Epoch. + */ + int CL_DEVICE_PROFILING_TIMER_OFFSET_AMD = 0x4036; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/AMD_fp64.java b/src/templates/org/lwjgl/opencl/AMD_fp64.java new file mode 100644 index 00000000..63236b13 --- /dev/null +++ b/src/templates/org/lwjgl/opencl/AMD_fp64.java @@ -0,0 +1,39 @@ +/* + * 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.util.generator.opencl.CLDeviceExtension; + +@CLDeviceExtension +public interface AMD_fp64 { + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/AMD_media_ops.java b/src/templates/org/lwjgl/opencl/AMD_media_ops.java new file mode 100644 index 00000000..db8308d6 --- /dev/null +++ b/src/templates/org/lwjgl/opencl/AMD_media_ops.java @@ -0,0 +1,39 @@ +/* + * 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.util.generator.opencl.CLDeviceExtension; + +@CLDeviceExtension +public interface AMD_media_ops { + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/AMD_printf.java b/src/templates/org/lwjgl/opencl/AMD_printf.java new file mode 100644 index 00000000..3aa67d03 --- /dev/null +++ b/src/templates/org/lwjgl/opencl/AMD_printf.java @@ -0,0 +1,39 @@ +/* + * 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.util.generator.opencl.CLDeviceExtension; + +@CLDeviceExtension +public interface AMD_printf { + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/APPLE_ContextLoggingFunctions.java b/src/templates/org/lwjgl/opencl/APPLE_ContextLoggingFunctions.java new file mode 100644 index 00000000..2bef7522 --- /dev/null +++ b/src/templates/org/lwjgl/opencl/APPLE_ContextLoggingFunctions.java @@ -0,0 +1,64 @@ +/* + * 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.util.generator.*; +import org.lwjgl.util.generator.opencl.CLDeviceExtension; +import org.lwjgl.util.generator.opencl.cl_char; +import org.lwjgl.util.generator.opencl.cl_void; +import org.lwjgl.util.generator.opencl.size_t; + +import java.nio.ByteBuffer; + +@Private +@CLDeviceExtension +public interface APPLE_ContextLoggingFunctions { + + @Extern + void clLogMessagesToSystemLogAPPLE(@Check @Const @cl_char ByteBuffer errstr, + @Const @cl_void ByteBuffer private_info, + @AutoSize("private_info") @size_t long cb, + @Check @cl_void ByteBuffer user_data); + + @Extern + void clLogMessagesToStdoutAPPLE(@Check @Const @cl_char ByteBuffer errstr, + @Const @cl_void ByteBuffer private_info, + @AutoSize("private_info") @size_t long cb, + @Check @cl_void ByteBuffer user_data); + + @Extern + void clLogMessagesToStderrAPPLE(@Check @Const @cl_char ByteBuffer errstr, + @Const @cl_void ByteBuffer private_info, + @AutoSize("private_info") @size_t long cb, + @Check @cl_void ByteBuffer user_data); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/APPLE_SetMemObjectDestructor.java b/src/templates/org/lwjgl/opencl/APPLE_SetMemObjectDestructor.java new file mode 100644 index 00000000..5a0960e6 --- /dev/null +++ b/src/templates/org/lwjgl/opencl/APPLE_SetMemObjectDestructor.java @@ -0,0 +1,55 @@ +/* + * 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.util.generator.Code; +import org.lwjgl.util.generator.Constant; +import org.lwjgl.util.generator.PointerWrapper; +import org.lwjgl.util.generator.opencl.CLDeviceExtension; +import org.lwjgl.util.generator.opencl.cl_int; + +@CLDeviceExtension +public interface APPLE_SetMemObjectDestructor { + + @Code( + tryBlock = true, + // Create a GlobalRef to the callback object. + javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);", + // Check if we need to delete the GlobalRef. + javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);" + ) + @cl_int + int clSetMemObjectDestructorAPPLE(@PointerWrapper("cl_mem") CLMem memobj, + @PointerWrapper("cl_mem_object_destructor_callback") CLMemObjectDestructorCallback pfn_notify, + @Constant("user_data") @PointerWrapper("void *") long user_data); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/APPLE_gl_sharing.java b/src/templates/org/lwjgl/opencl/APPLE_gl_sharing.java new file mode 100644 index 00000000..bc07cbcb --- /dev/null +++ b/src/templates/org/lwjgl/opencl/APPLE_gl_sharing.java @@ -0,0 +1,78 @@ +/* + * 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.PointerBuffer; +import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opencl.CLDeviceExtension; +import org.lwjgl.util.generator.opencl.cl_int; +import org.lwjgl.util.generator.opencl.cl_void; +import org.lwjgl.util.generator.opencl.size_t; + +import java.nio.ByteBuffer; + +@CLDeviceExtension +@Extension(postfix = "APPLE", className = "APPLEGLSharing") +public interface APPLE_gl_sharing { + + /** + * This enumerated value can be specified as part of the <properties> argument passed to clCreateContext + * to allow OpenCL compliant devices in an existing CGL share group to be used as the devices in + * the newly created CL context. GL objects that were allocated in the given CGL share group can + * now be shared between CL and GL. + */ + int CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE = 0x10000000; + + /** + * Returns a cl_device_id for the CL device associated with the virtual screen for + * the given CGL context. Return type: cl_device_id + */ + int CL_CGL_DEVICE_FOR_CURRENT_VIRTUAL_SCREEN_APPLE = 0x10000002; + + /** + * Returns an array of cl_device_ids for the CL device(s) corresponding to + * the virtual screen(s) for the given CGL context. Return type: cl_device_id[] + */ + int CL_CGL_DEVICES_FOR_SUPPORTED_VIRTUAL_SCREENS_APPLE = 0x10000003; + + /** Error code returned by clGetGLContextInfoAPPLE if an invalid platform_gl_ctx is provided */ + int CL_INVALID_GL_CONTEXT_APPLE = -1000; + + @cl_int + int clGetGLContextInfoAPPLE(@PointerWrapper("cl_context") CLContext context, + @Check("1") @NativeType("cl_void") PointerBuffer platform_gl_ctx, + @NativeType("cl_gl_platform_info") int param_name, + @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size, + @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/CL10.java b/src/templates/org/lwjgl/opencl/CL10.java new file mode 100644 index 00000000..d39a0d2f --- /dev/null +++ b/src/templates/org/lwjgl/opencl/CL10.java @@ -0,0 +1,1084 @@ +/* + * 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.PointerBuffer; +import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opencl.*; + +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +/** The core OpenCL 1.0 API */ +public interface CL10 { + + /** Error Codes */ + int CL_SUCCESS = 0, + CL_DEVICE_NOT_FOUND = -1, + CL_DEVICE_NOT_AVAILABLE = -2, + CL_COMPILER_NOT_AVAILABLE = -3, + CL_MEM_OBJECT_ALLOCATION_FAILURE = -4, + CL_OUT_OF_RESOURCES = -5, + CL_OUT_OF_HOST_MEMORY = -6, + CL_PROFILING_INFO_NOT_AVAILABLE = -7, + CL_MEM_COPY_OVERLAP = -8, + CL_IMAGE_FORMAT_MISMATCH = -9, + CL_IMAGE_FORMAT_NOT_SUPPORTED = -10, + CL_BUILD_PROGRAM_FAILURE = -11, + CL_MAP_FAILURE = -12, + + CL_INVALID_VALUE = -30, + CL_INVALID_DEVICE_TYPE = -31, + CL_INVALID_PLATFORM = -32, + CL_INVALID_DEVICE = -33, + CL_INVALID_CONTEXT = -34, + CL_INVALID_QUEUE_PROPERTIES = -35, + CL_INVALID_COMMAND_QUEUE = -36, + CL_INVALID_HOST_PTR = -37, + CL_INVALID_MEM_OBJECT = -38, + CL_INVALID_IMAGE_FORMAT_DESCRIPTOR = -39, + CL_INVALID_IMAGE_SIZE = -40, + CL_INVALID_SAMPLER = -41, + CL_INVALID_BINARY = -42, + CL_INVALID_BUILD_OPTIONS = -43, + CL_INVALID_PROGRAM = -44, + CL_INVALID_PROGRAM_EXECUTABLE = -45, + CL_INVALID_KERNEL_NAME = -46, + CL_INVALID_KERNEL_DEFINITION = -47, + CL_INVALID_KERNEL = -48, + CL_INVALID_ARG_INDEX = -49, + CL_INVALID_ARG_VALUE = -50, + CL_INVALID_ARG_SIZE = -51, + CL_INVALID_KERNEL_ARGS = -52, + CL_INVALID_WORK_DIMENSION = -53, + CL_INVALID_WORK_GROUP_SIZE = -54, + CL_INVALID_WORK_ITEM_SIZE = -55, + CL_INVALID_GLOBAL_OFFSET = -56, + CL_INVALID_EVENT_WAIT_LIST = -57, + CL_INVALID_EVENT = -58, + CL_INVALID_OPERATION = -59, + CL_INVALID_GL_OBJECT = -60, + CL_INVALID_BUFFER_SIZE = -61, + CL_INVALID_MIP_LEVEL = -62, + CL_INVALID_GLOBAL_WORK_SIZE = -63; + + /** OpenCL Version */ + int CL_VERSION_1_0 = 1; + + /** cl_bool */ + int CL_FALSE = 0, + CL_TRUE = 1; + + /** cl_platform_info */ + int CL_PLATFORM_PROFILE = 0x0900, + CL_PLATFORM_VERSION = 0x0901, + CL_PLATFORM_NAME = 0x0902, + CL_PLATFORM_VENDOR = 0x0903, + CL_PLATFORM_EXTENSIONS = 0x0904; + + /** cl_device_type - bitfield */ + int CL_DEVICE_TYPE_DEFAULT = (1 << 0), + CL_DEVICE_TYPE_CPU = (1 << 1), + CL_DEVICE_TYPE_GPU = (1 << 2), + CL_DEVICE_TYPE_ACCELERATOR = (1 << 3), + CL_DEVICE_TYPE_ALL = 0xFFFFFFFF; + + /** cl_device_info */ + int CL_DEVICE_TYPE = 0x1000, + CL_DEVICE_VENDOR_ID = 0x1001, + CL_DEVICE_MAX_COMPUTE_UNITS = 0x1002, + CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS = 0x1003, + CL_DEVICE_MAX_WORK_GROUP_SIZE = 0x1004, + CL_DEVICE_MAX_WORK_ITEM_SIZES = 0x1005, + CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR = 0x1006, + CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT = 0x1007, + CL_DEVICE_PREFERRED_VECTOR_WIDTH_ = 0x1008, + CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG = 0x1009, + CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT = 0x100A, + CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE = 0x100B, + CL_DEVICE_MAX_CLOCK_FREQUENCY = 0x100C, + CL_DEVICE_ADDRESS_BITS = 0x100D, + CL_DEVICE_MAX_READ_IMAGE_ARGS = 0x100E, + CL_DEVICE_MAX_WRITE_IMAGE_ARGS = 0x100F, + CL_DEVICE_MAX_MEM_ALLOC_SIZE = 0x1010, + CL_DEVICE_IMAGE2D_MAX_WIDTH = 0x1011, + CL_DEVICE_IMAGE2D_MAX_HEIGHT = 0x1012, + CL_DEVICE_IMAGE3D_MAX_WIDTH = 0x1013, + CL_DEVICE_IMAGE3D_MAX_HEIGHT = 0x1014, + CL_DEVICE_IMAGE3D_MAX_DEPTH = 0x1015, + CL_DEVICE_IMAGE_SUPPORT = 0x1016, + CL_DEVICE_MAX_PARAMETER_SIZE = 0x1017, + CL_DEVICE_MAX_SAMPLERS = 0x1018, + CL_DEVICE_MEM_BASE_ADDR_ALIGN = 0x1019, + CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE = 0x101A, + CL_DEVICE_SINGLE_FP_CONFIG = 0x101B, + CL_DEVICE_GLOBAL_MEM_CACHE_TYPE = 0x101C, + CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE = 0x101D, + CL_DEVICE_GLOBAL_MEM_CACHE_SIZE = 0x101E, + CL_DEVICE_GLOBAL_MEM_SIZE = 0x101F, + CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE = 0x1020, + CL_DEVICE_MAX_CONSTANT_ARGS = 0x1021, + CL_DEVICE_LOCAL_MEM_TYPE = 0x1022, + CL_DEVICE_LOCAL_MEM_SIZE = 0x1023, + CL_DEVICE_ERROR_CORRECTION_SUPPORT = 0x1024, + CL_DEVICE_PROFILING_TIMER_RESOLUTION = 0x1025, + CL_DEVICE_ENDIAN_LITTLE = 0x1026, + CL_DEVICE_AVAILABLE = 0x1027, + CL_DEVICE_COMPILER_AVAILABLE = 0x1028, + CL_DEVICE_EXECUTION_CAPABILITIES = 0x1029, + CL_DEVICE_QUEUE_PROPERTIES = 0x102A, + CL_DEVICE_NAME = 0x102B, + CL_DEVICE_VENDOR = 0x102C, + CL_DRIVER_VERSION = 0x102D, + CL_DEVICE_PROFILE = 0x102E, + CL_DEVICE_VERSION = 0x102F, + CL_DEVICE_EXTENSIONS = 0x1030, + CL_DEVICE_PLATFORM = 0x1031; + /* 0x1032 reserved for CL_DEVICE_DOUBLE_FP_CONFIG */ + /* 0x1033 reserved for CL_DEVICE_HALF_FP_CONFIG */ + + /** cl_device_fp_config - bitfield */ + int CL_FP_DENORM = (1 << 0), + CL_FP_INF_NAN = (1 << 1), + CL_FP_ROUND_TO_NEAREST = (1 << 2), + CL_FP_ROUND_TO_ZERO = (1 << 3), + CL_FP_ROUND_TO_INF = (1 << 4), + CL_FP_FMA = (1 << 5); + + /** cl_device_mem_cache_type */ + int CL_NONE = 0x0, + CL_READ_ONLY_CACHE = 0x1, + CL_READ_WRITE_CACHE = 0x2; + + /** cl_device_local_mem_type */ + int CL_LOCAL = 0x1, + CL_GLOBAL = 0x2; + + /** cl_device_exec_capabilities - bitfield */ + int CL_EXEC_KERNEL = (1 << 0), + CL_EXEC_NATIVE_KERNEL = (1 << 1); + + /** cl_command_queue_properties - bitfield */ + int CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE = (1 << 0), + CL_QUEUE_PROFILING_ENABLE = (1 << 1); + + /** cl_context_info */ + int CL_CONTEXT_REFERENCE_COUNT = 0x1080, + CL_CONTEXT_DEVICES = 0x1081, + CL_CONTEXT_PROPERTIES = 0x1082; + + /** cl_context_info + cl_context_properties */ + int CL_CONTEXT_PLATFORM = 0x1084; + + /** cl_command_queue_info */ + int CL_QUEUE_CONTEXT = 0x1090, + CL_QUEUE_DEVICE = 0x1091, + CL_QUEUE_REFERENCE_COUNT = 0x1092, + CL_QUEUE_PROPERTIES = 0x1093; + + /** cl_mem_flags - bitfield */ + int CL_MEM_READ_WRITE = (1 << 0), + CL_MEM_WRITE_ONLY = (1 << 1), + CL_MEM_READ_ONLY = (1 << 2), + CL_MEM_USE_HOST_PTR = (1 << 3), + CL_MEM_ALLOC_HOST_PTR = (1 << 4), + CL_MEM_COPY_HOST_PTR = (1 << 5); + + /** cl_channel_order */ + int CL_R = 0x10B0, + CL_A = 0x10B1, + CL_RG = 0x10B2, + CL_RA = 0x10B3, + CL_RGB = 0x10B4, + CL_RGBA = 0x10B5, + CL_BGRA = 0x10B6, + CL_ARGB = 0x10B7, + CL_INTENSITY = 0x10B8, + CL_LUMINANCE = 0x10B9; + + /** cl_channel_type */ + int CL_SNORM_INT8 = 0x10D0, + CL_SNORM_INT16 = 0x10D1, + CL_UNORM_INT8 = 0x10D2, + CL_UNORM_INT16 = 0x10D3, + CL_UNORM_SHORT_565 = 0x10D4, + CL_UNORM_SHORT_555 = 0x10D5, + CL_UNORM_INT_101010 = 0x10D6, + CL_SIGNED_INT8 = 0x10D7, + CL_SIGNED_INT16 = 0x10D8, + CL_SIGNED_INT32 = 0x10D9, + CL_UNSIGNED_INT8 = 0x10DA, + CL_UNSIGNED_INT16 = 0x10DB, + CL_UNSIGNED_INT32 = 0x10DC, + CL_HALF_FLOAT = 0x10DD, + CL_FLOAT = 0x10DE; + + /** cl_mem_object_type */ + int CL_MEM_OBJECT_BUFFER = 0x10F0, + CL_MEM_OBJECT_IMAGE2D = 0x10F1, + CL_MEM_OBJECT_IMAGE3D = 0x10F2; + + /** cl_mem_info */ + int CL_MEM_TYPE = 0x1100, + CL_MEM_FLAGS = 0x1101, + CL_MEM_SIZE = 0x1102, + CL_MEM_HOST_PTR = 0x1103, + CL_MEM_MAP_COUNT = 0x1104, + CL_MEM_REFERENCE_COUNT = 0x1105, + CL_MEM_CONTEXT = 0x1106; + + /** cl_image_info */ + int CL_IMAGE_FORMAT = 0x1110, + CL_IMAGE_ELEMENT_SIZE = 0x1111, + CL_IMAGE_ROW_PITCH = 0x1112, + CL_IMAGE_SLICE_PITCH = 0x1113, + CL_IMAGE_WIDTH = 0x1114, + CL_IMAGE_HEIGHT = 0x1115, + CL_IMAGE_DEPTH = 0x1116; + + /** cl_addressing_mode */ + int CL_ADDRESS_NONE = 0x1130, + CL_ADDRESS_CLAMP_TO_EDGE = 0x1131, + CL_ADDRESS_CLAMP = 0x1132, + CL_ADDRESS_REPEAT = 0x1133; + + /** cl_filter_mode */ + int CL_FILTER_NEAREST = 0x1140, + CL_FILTER_LINEAR = 0x1141; + + /** cl_sampler_info */ + int CL_SAMPLER_REFERENCE_COUNT = 0x1150, + CL_SAMPLER_CONTEXT = 0x1151, + CL_SAMPLER_NORMALIZED_COORDS = 0x1152, + CL_SAMPLER_ADDRESSING_MODE = 0x1153, + CL_SAMPLER_FILTER_MODE = 0x1154; + + /** cl_map_flags - bitfield */ + int CL_MAP_READ = (1 << 0), + CL_MAP_WRITE = (1 << 1); + + /** cl_program_info */ + int CL_PROGRAM_REFERENCE_COUNT = 0x1160, + CL_PROGRAM_CONTEXT = 0x1161, + CL_PROGRAM_NUM_DEVICES = 0x1162, + CL_PROGRAM_DEVICES = 0x1163, + CL_PROGRAM_SOURCE = 0x1164, + CL_PROGRAM_BINARY_SIZES = 0x1165, + CL_PROGRAM_BINARIES = 0x1166; + + /** cl_program_build_info */ + int CL_PROGRAM_BUILD_STATUS = 0x1181, + CL_PROGRAM_BUILD_OPTIONS = 0x1182, + CL_PROGRAM_BUILD_LOG = 0x1183; + + /** cl_build_status */ + int CL_BUILD_SUCCESS = 0, + CL_BUILD_NONE = -1, + CL_BUILD_ERROR = -2, + CL_BUILD_IN_PROGRESS = -3; + + /** cl_kernel_info */ + int CL_KERNEL_FUNCTION_NAME = 0x1190, + CL_KERNEL_NUM_ARGS = 0x1191, + CL_KERNEL_REFERENCE_COUNT = 0x1192, + CL_KERNEL_CONTEXT = 0x1193, + CL_KERNEL_PROGRAM = 0x1194; + + /** cl_kernel_work_group_info */ + int CL_KERNEL_WORK_GROUP_SIZE = 0x11B0, + CL_KERNEL_COMPILE_WORK_GROUP_SIZE = 0x11B1, + CL_KERNEL_LOCAL_MEM_SIZE = 0x11B2; + + /** cl_event_info */ + int CL_EVENT_COMMAND_QUEUE = 0x11D0, + CL_EVENT_COMMAND_TYPE = 0x11D1, + CL_EVENT_REFERENCE_COUNT = 0x11D2, + CL_EVENT_COMMAND_EXECUTION_STATUS = 0x11D3; + + /** cl_command_type */ + int CL_COMMAND_NDRANGE_KERNEL = 0x11F0, + CL_COMMAND_TASK = 0x11F1, + CL_COMMAND_NATIVE_KERNEL = 0x11F2, + CL_COMMAND_READ_BUFFER = 0x11F3, + CL_COMMAND_WRITE_BUFFER = 0x11F4, + CL_COMMAND_COPY_BUFFER = 0x11F5, + CL_COMMAND_READ_IMAGE = 0x11F6, + CL_COMMAND_WRITE_IMAGE = 0x11F7, + CL_COMMAND_COPY_IMAGE = 0x11F8, + CL_COMMAND_COPY_IMAGE_TO_BUFFER = 0x11F9, + CL_COMMAND_COPY_BUFFER_TO_IMAGE = 0x11FA, + CL_COMMAND_MAP_BUFFER = 0x11FB, + CL_COMMAND_MAP_IMAGE = 0x11FC, + CL_COMMAND_UNMAP_MEM_OBJECT = 0x11FD, + CL_COMMAND_MARKER = 0x11FE, + CL_COMMAND_ACQUIRE_GL_OBJECTS = 0x11FF, + CL_COMMAND_RELEASE_GL_OBJECTS = 0x1200; + + /** command execution status */ + int CL_COMPLETE = 0x0, + CL_RUNNING = 0x1, + CL_SUBMITTED = 0x2, + CL_QUEUED = 0x3; + + /** cl_profiling_info */ + int CL_PROFILING_COMMAND_QUEUED = 0x1280, + CL_PROFILING_COMMAND_SUBMIT = 0x1281, + CL_PROFILING_COMMAND_START = 0x1282, + CL_PROFILING_COMMAND_END = 0x1283; + + /* Platform API */ + + @cl_int + int clGetPlatformIDs(@AutoSize(value = "platforms", canBeNull = true) @cl_uint int num_entries, + @OutParameter @Check(canBeNull = true) @NativeType("cl_platform_id") PointerBuffer platforms, + @OutParameter @Check(value = "1", canBeNull = true) @cl_uint IntBuffer num_platforms); + + @cl_int + int clGetPlatformInfo(@PointerWrapper(value = "cl_platform_id", canBeNull = true) CLPlatform platform, + @NativeType("cl_platform_info") int param_name, + @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size, + @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret); + + @cl_int + int clGetDeviceIDs(@PointerWrapper(value = "cl_platform_id", canBeNull = true) CLPlatform platform, + @NativeType("cl_device_type") long device_type, + @AutoSize(value = "devices", canBeNull = true) @cl_uint int num_entries, + @OutParameter @Check(canBeNull = true) @NativeType("cl_device_id") PointerBuffer devices, + @OutParameter @Check(value = "1", canBeNull = true) @cl_uint IntBuffer num_devices); + + @cl_int + int clGetDeviceInfo(@PointerWrapper("cl_device_id") CLDevice device, + @NativeType("cl_device_info") int param_name, + @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size, + @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret); + + @Code( + tryBlock = true, + // Create a GlobalRef to the callback object. + 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);" + ) + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper("cl_context") + CLContext clCreateContext(@NullTerminated @Check(canBeNull = true) @Const @NativeType("cl_context_properties") PointerBuffer properties, + @AutoSize("devices") @cl_uint int num_devices, + @Check("1") @Const @NativeType("cl_device_id") PointerBuffer devices, + @PointerWrapper(value = "cl_create_context_callback", canBeNull = true) CLContextCallback pfn_notify, + @Constant("user_data") @PointerWrapper("void *") long user_data, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Alternate("clCreateContext") + @Code( + tryBlock = true, + // Create a GlobalRef to the callback object. + 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);" + ) + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper("cl_context") + CLContext clCreateContext(@NullTerminated @Check(canBeNull = true) @Const @NativeType("cl_context_properties") PointerBuffer properties, + @Constant("1") @cl_uint int num_devices, + @Constant(value = "APIUtil.getBufferPointer().put(0, device).getBuffer(), 0", keepParam = true) CLDevice device, + @PointerWrapper(value = "cl_create_context_callback", canBeNull = true) CLContextCallback pfn_notify, + @Constant("user_data") @PointerWrapper("void *") long user_data, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Code( + tryBlock = true, + // Create a GlobalRef to the callback object. + javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);", + // Associate context with the GlobalRef, so we can delete it later. + javaFinally = "\t\t\tCallbackUtil.registerCallback(__result, user_data);" + ) + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper("cl_context") + CLContext clCreateContextFromType(@NullTerminated @Check(canBeNull = true) @Const @NativeType("cl_context_properties") PointerBuffer properties, + @NativeType("cl_device_type") long device_type, + @PointerWrapper(value = "cl_create_context_callback", canBeNull = true) CLContextCallback pfn_notify, + @Constant("user_data") @PointerWrapper("void *") long user_data, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) context.retain();") + @cl_int + int clRetainContext(@PointerWrapper("cl_context") CLContext context); + + @Code( + javaBeforeNative = "\t\tAPIUtil.releaseObjects(context);", + javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) CallbackUtil.unregisterCallback(context);" + ) + @cl_int + int clReleaseContext(@PointerWrapper("cl_context") CLContext context); + + @cl_int + int clGetContextInfo(@PointerWrapper("cl_context") CLContext context, + @NativeType("cl_context_info") int param_name, + @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size, + @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret); + + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_command_queue", params = "context, device") + CLCommandQueue clCreateCommandQueue(@PointerWrapper("cl_context") CLContext context, + @PointerWrapper("cl_device_id") CLDevice device, + @NativeType("cl_command_queue_properties") long properties, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.retain();") + @cl_int + int clRetainCommandQueue(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue); + + @Code( + javaBeforeNative = "\t\tAPIUtil.releaseObjects(command_queue);", + javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.release();" + ) + @cl_int + int clReleaseCommandQueue(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue); + + @cl_int + int clGetCommandQueueInfo(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @NativeType("cl_command_queue_info") int param_name, + @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size, + @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret); + + @GenerateAutos + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_mem", params = "context") + CLMem clCreateBuffer(@PointerWrapper("cl_context") CLContext context, + @NativeType("cl_mem_flags") long flags, + @AutoSize("host_ptr") @size_t long size, + @cl_byte + @cl_short + @cl_int + @cl_long + @cl_float + @cl_double Buffer host_ptr, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);") + @cl_int + int clEnqueueReadBuffer(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @PointerWrapper("cl_mem") CLMem buffer, + @cl_bool int blocking_read, + @size_t long offset, + @AutoSize("ptr") @size_t long cb, + @OutParameter + @cl_byte + @cl_short + @cl_int + @cl_long + @cl_float + @cl_double Buffer ptr, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);") + @cl_int + int clEnqueueWriteBuffer(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @PointerWrapper("cl_mem") CLMem buffer, + @cl_bool int blocking_write, + @size_t long offset, + @AutoSize("ptr") @size_t long cb, + @Const + @cl_byte + @cl_short + @cl_int + @cl_long + @cl_float + @cl_double Buffer ptr, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);") + @cl_int + int clEnqueueCopyBuffer(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @PointerWrapper("cl_mem") CLMem src_buffer, + @PointerWrapper("cl_mem") CLMem dst_buffer, + @size_t long src_offset, + @size_t long dst_offset, + @size_t long cb, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @Code(javaAfterNative = "\t\tif ( __result != null ) command_queue.registerCLEvent(event);") + @Check(value = "errcode_ret", canBeNull = true) + @cl_void + @AutoSize("cb") + ByteBuffer clEnqueueMapBuffer(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @PointerWrapper("cl_mem") CLMem buffer, + @cl_bool int blocking_map, + @NativeType("cl_map_flags") long map_flags, + @size_t long offset, + @size_t long cb, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_mem", params = "context") + CLMem clCreateImage2D(@PointerWrapper("cl_context") CLContext context, + @NativeType("cl_mem_flags") long flags, + @Check("2 * 4") @Const @NativeType("cl_image_format") ByteBuffer image_format, + @size_t long image_width, + @size_t long image_height, + @size_t long image_row_pitch, + @Check(value = "CLChecks.calculateImage2DSize(image_format, image_width, image_height, image_row_pitch)", canBeNull = true) + @cl_byte + @cl_short + @cl_int + @cl_float Buffer host_ptr, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_mem", params = "context") + CLMem clCreateImage3D(@PointerWrapper("cl_context") CLContext context, + @NativeType("cl_mem_flags") long flags, + @Check("2 * 4") @Const @NativeType("cl_image_format") ByteBuffer image_format, + @size_t long image_width, + @size_t long image_height, + @size_t long image_depth, + @size_t long image_row_pitch, + @size_t long image_slice_pitch, + @Check(value = "CLChecks.calculateImage3DSize(image_format, image_width, image_height, image_height, image_row_pitch, image_slice_pitch)", canBeNull = true) + @cl_byte + @cl_short + @cl_int + @cl_float Buffer host_ptr, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @cl_int + int clGetSupportedImageFormats(@PointerWrapper("cl_context") CLContext context, + @NativeType("cl_mem_flags") long flags, + @NativeType("cl_mem_object_type") int image_type, + @AutoSize(value = "image_formats", expression = " / (2 * 4)", canBeNull = true) @cl_uint int num_entries, + @OutParameter @Check(canBeNull = true) @NativeType("cl_image_format") ByteBuffer image_formats, + @OutParameter @Check(value = "1", canBeNull = true) @cl_uint IntBuffer num_image_formats); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);") + @cl_int + int clEnqueueReadImage(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @PointerWrapper("cl_mem") CLMem image, + @cl_bool int blocking_read, + @Check("3") @Const @NativeType("size_t") PointerBuffer origin, + @Check("3") @Const @NativeType("size_t") PointerBuffer region, + @size_t long row_pitch, + @size_t long slice_pitch, + @OutParameter @Check("CLChecks.calculateImageSize(region, row_pitch, slice_pitch)") + @cl_byte + @cl_short + @cl_int + @cl_float Buffer ptr, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);") + @cl_int + int clEnqueueWriteImage(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @PointerWrapper("cl_mem") CLMem image, + @cl_bool int blocking_write, + @Check("3") @Const @NativeType("size_t") PointerBuffer origin, + @Check("3") @Const @NativeType("size_t") PointerBuffer region, + @size_t long input_row_pitch, + @size_t long input_slice_pitch, + @Check("CLChecks.calculateImageSize(region, input_row_pitch, input_slice_pitch)") @Const + @cl_byte + @cl_short + @cl_int + @cl_float Buffer ptr, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);") + @cl_int + int clEnqueueCopyImage(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @PointerWrapper("cl_mem") CLMem src_image, + @PointerWrapper("cl_mem") CLMem dst_image, + @Check("3") @Const @NativeType("size_t") PointerBuffer src_origin, + @Check("3") @Const @NativeType("size_t") PointerBuffer dst_origin, + @Check("3") @Const @NativeType("size_t") PointerBuffer region, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);") + @cl_int + int clEnqueueCopyImageToBuffer(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @PointerWrapper("cl_mem") CLMem src_image, + @PointerWrapper("cl_mem") CLMem dst_buffer, + @Check("3") @Const @NativeType("size_t") PointerBuffer src_origin, + @Check("3") @Const @NativeType("size_t") PointerBuffer region, + @size_t long dst_offset, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);") + @cl_int + int clEnqueueCopyBufferToImage(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @PointerWrapper("cl_mem") CLMem src_buffer, + @PointerWrapper("cl_mem") CLMem dst_image, + @size_t long src_offset, + @Check("3") @Const @NativeType("size_t") PointerBuffer dst_origin, + @Check("3") @Const @NativeType("size_t") PointerBuffer region, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @Code(javaAfterNative = "\t\tif ( __result != null ) command_queue.registerCLEvent(event);") + @Check(value = "errcode_ret", canBeNull = true) + @cl_void + @AutoSize(value = "extcl_CalculateImageSize(region_address, *image_row_pitch_address, image_slice_pitch == NULL ? 0 : *image_slice_pitch_address)", isNative = true) + ByteBuffer clEnqueueMapImage(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @PointerWrapper("cl_mem") CLMem image, + @cl_bool int blocking_map, + @NativeType("cl_map_flags") long map_flags, + @Check("3") @Const @NativeType("size_t") PointerBuffer origin, + @Check("3") @Const @NativeType("size_t") PointerBuffer region, + @OutParameter @Check("1") @NativeType("size_t") PointerBuffer image_row_pitch, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer image_slice_pitch, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @cl_int + int clGetImageInfo(@PointerWrapper("cl_mem") CLMem image, + @NativeType("cl_image_info") int param_name, + @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size, + @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) memobj.retain();") + @cl_int + int clRetainMemObject(@PointerWrapper("cl_mem") CLMem memobj); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) memobj.release();") + @cl_int + int clReleaseMemObject(@PointerWrapper("cl_mem") CLMem memobj); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);") + @cl_int + int clEnqueueUnmapMemObject(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @PointerWrapper("cl_mem") CLMem memobj, + @Check @cl_void ByteBuffer mapped_ptr, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @cl_int + int clGetMemObjectInfo(@PointerWrapper("cl_mem") CLMem memobj, + @NativeType("cl_mem_info") int param_name, + @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size, + @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret); + + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_sampler", params = "context") + CLSampler clCreateSampler(@PointerWrapper("cl_context") CLContext context, + @cl_bool int normalized_coords, + @NativeType("cl_addressing_mode") int addressing_mode, + @NativeType("cl_filter_mode") int filter_mode, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) sampler.retain();") + @cl_int + int clRetainSampler(@PointerWrapper("cl_sampler") CLSampler sampler); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) sampler.release();") + @cl_int + int clReleaseSampler(@PointerWrapper("cl_sampler") CLSampler sampler); + + @cl_int + int clGetSamplerInfo(@PointerWrapper("cl_sampler") CLSampler sampler, + @NativeType("cl_sampler_info") int param_name, + @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size, + @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret); + + // ------[ clCreateProgramWithSource ]------ + + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_program", params = "context") + CLProgram clCreateProgramWithSource(@PointerWrapper("cl_context") CLContext context, + @Constant("1") @cl_uint int count, + @Check @Indirect @Const @cl_char ByteBuffer string, + @AutoSize("string") @Indirect @Const @size_t long lengths, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Alternate(value = "clCreateProgramWithSource", nativeAlt = true) + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_program", params = "context") + CLProgram clCreateProgramWithSource2(@PointerWrapper("cl_context") CLContext context, + @AutoSize("lengths") @cl_uint int count, + @Check("APIUtil.getSize(lengths)") @PointerArray(value = "count", lengths = "lengths") @Const @NativeType("cl_char") ByteBuffer strings, + @Check("1") @Const @NativeType("size_t") PointerBuffer lengths, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Alternate(value = "clCreateProgramWithSource", nativeAlt = true) + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_program", params = "context") + CLProgram clCreateProgramWithSource3(@PointerWrapper("cl_context") CLContext context, + @Constant("strings.length") @cl_uint int count, + @Check("1") @PointerArray(value = "count") @Const @NativeType("cl_char") ByteBuffer[] strings, + @Constant("APIUtil.getLengths(strings).getBuffer(), 0") @Const @NativeType("size_t") PointerBuffer lengths, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Alternate("clCreateProgramWithSource") + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_program", params = "context") + CLProgram clCreateProgramWithSource(@PointerWrapper("cl_context") CLContext context, + @Constant("1") @cl_uint int count, + CharSequence string, + @Constant("string.length()") @Indirect @Const @size_t long lengths, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Alternate(value = "clCreateProgramWithSource", nativeAlt = true) + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_program", params = "context") + CLProgram clCreateProgramWithSource4(@PointerWrapper("cl_context") CLContext context, + @Constant("strings.length") @cl_uint int count, + @Const @PointerArray(value = "count", lengths = "lengths") CharSequence[] strings, + @Constant("APIUtil.getLengths(strings).getBuffer(), 0") @Const @NativeType("size_t") PointerBuffer lengths, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + // ------[ clCreateProgramWithBinary ]------ + + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_program", params = "context") + CLProgram clCreateProgramWithBinary(@PointerWrapper("cl_context") CLContext context, + @Constant("1") @cl_uint int num_devices, + @Const @Indirect @PointerWrapper("cl_device_id") CLDevice device, + @AutoSize("binary") @Const @Indirect @size_t long lengths, + @Const @Indirect @cl_uchar ByteBuffer binary, + @OutParameter @Check("1") @cl_int IntBuffer binary_status, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Alternate(value = "clCreateProgramWithBinary", nativeAlt = true) + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_program", params = "context") + CLProgram clCreateProgramWithBinary2(@PointerWrapper("cl_context") CLContext context, + @AutoSize("device_list") @cl_uint int num_devices, + @Check("1") @Const @NativeType("cl_device_id") PointerBuffer device_list, + @Check("device_list.remaining()") @Const @NativeType("size_t") PointerBuffer lengths, + @Check("APIUtil.getSize(lengths)") @PointerArray(value = "num_devices", lengths = "lengths") @Const @NativeType("cl_uchar") ByteBuffer binaries, + @OutParameter @Check("device_list.remaining()") @cl_int IntBuffer binary_status, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Alternate(value = "clCreateProgramWithBinary", nativeAlt = true) + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_program", params = "context") + CLProgram clCreateProgramWithBinary3(@PointerWrapper("cl_context") CLContext context, + @Constant("binaries.length") @cl_uint int num_devices, + @Check("binaries.length") @Const @NativeType("cl_device_id") PointerBuffer device_list, + @Constant("APIUtil.getLengths(binaries).getBuffer(), 0") @Const @NativeType("size_t") PointerBuffer lengths, + @Check("1") @PointerArray("num_devices") @Const @NativeType("cl_uchar") ByteBuffer[] binaries, + @OutParameter @Check("binaries.length") @cl_int IntBuffer binary_status, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) program.retain();") + @cl_int + int clRetainProgram(@PointerWrapper("cl_program") CLProgram program); + + @Code( + javaBeforeNative = "\t\tAPIUtil.releaseObjects(program);", + javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) program.release();" + ) + @cl_int + int clReleaseProgram(@PointerWrapper("cl_program") CLProgram program); + + @Code( + tryBlock = true, + // Create a GlobalRef to the callback object. + javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);", + // Check if we need to delete the GlobalRef. + javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);" + ) + @cl_int + int clBuildProgram(@PointerWrapper("cl_program") CLProgram program, + @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices, + @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list, + @Check @NullTerminated @Const @cl_char ByteBuffer options, + @PointerWrapper(value = "cl_build_program_callback", canBeNull = true) CLBuildProgramCallback pfn_notify, + @Constant("user_data") @PointerWrapper("void *") long user_data); + + @Alternate("clBuildProgram") + @Code( + tryBlock = true, + // Create a GlobalRef to the callback object. + javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);", + // Check if we need to delete the GlobalRef. + javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);" + ) + @cl_int + int clBuildProgram(@PointerWrapper("cl_program") CLProgram program, + @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices, + @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list, + @NullTerminated @Const CharSequence options, + @PointerWrapper(value = "cl_build_program_callback", canBeNull = true) CLBuildProgramCallback pfn_notify, + @Constant("user_data") @PointerWrapper("void *") long user_data); + + @Alternate("clBuildProgram") + @Code( + tryBlock = true, + // Create a GlobalRef to the callback object. + javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);", + // Check if we need to delete the GlobalRef. + javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);" + ) + @cl_int + int clBuildProgram(@PointerWrapper("cl_program") CLProgram program, + @Constant("1") @cl_uint int num_devices, + @Constant(value = "APIUtil.getBufferPointer().put(0, device).getBuffer(), 0", keepParam = true) CLDevice device, + @NullTerminated @Const CharSequence options, + @PointerWrapper(value = "cl_build_program_callback", canBeNull = true) CLBuildProgramCallback pfn_notify, + @Constant("user_data") @PointerWrapper("void *") long user_data); + + @cl_int + int clUnloadCompiler(); + + @cl_int + int clGetProgramInfo(@PointerWrapper("cl_program") CLProgram program, + @NativeType("cl_program_info") int param_name, + @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size, + @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret); + + @cl_int + int clGetProgramBuildInfo(@PointerWrapper("cl_program") CLProgram program, + @PointerWrapper("cl_device_id") CLDevice device, + @NativeType("cl_program_build_info") int param_name, + @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size, + @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret); + + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_kernel", params = "program") + CLKernel clCreateKernel(@PointerWrapper("cl_program") CLProgram program, + @NullTerminated @Const @cl_char ByteBuffer kernel_name, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Alternate("clCreateKernel") + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_kernel", params = "program") + CLKernel clCreateKernel(@PointerWrapper("cl_program") CLProgram program, + @NullTerminated @Const CharSequence kernel_name, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS && kernels != null ) program.registerCLKernels(kernels);") + @cl_int + int clCreateKernelsInProgram(@PointerWrapper("cl_program") CLProgram program, + @AutoSize(value = "kernels", canBeNull = true) @cl_uint int num_kernels, + @OutParameter @Check(canBeNull = true) @NativeType("cl_kernel") PointerBuffer kernels, + @OutParameter @Check(value = "1", canBeNull = true) @cl_uint IntBuffer num_kernels_ret); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) kernel.retain();") + @cl_int + int clRetainKernel(@PointerWrapper("cl_kernel") CLKernel kernel); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) kernel.release();") + @cl_int + int clReleaseKernel(@PointerWrapper("cl_kernel") CLKernel kernel); + + @cl_int + int clSetKernelArg(@PointerWrapper("cl_kernel") CLKernel kernel, + @cl_uint int arg_index, + @AutoSize(value = "arg_value", canBeNull = true) @size_t long arg_size, + @Check(canBeNull = true) @Const + @cl_byte + @cl_short + @cl_int + @cl_long + @cl_float + @cl_double Buffer arg_value); + + // This is used by CLKernelImpl. Assumes arg_value.position() == 0. + + @Alternate("clSetKernelArg") + @Private + @cl_int + int clSetKernelArg2(@PointerWrapper("cl_kernel") CLKernel kernel, + @cl_uint int arg_index, + @size_t long arg_size, + @Check(value = "1") @Const Buffer arg_value); + + @cl_int + int clGetKernelInfo(@PointerWrapper("cl_kernel") CLKernel kernel, + @NativeType("cl_kernel_info") int param_name, + @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size, + @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret); + + @cl_int + int clGetKernelWorkGroupInfo(@PointerWrapper("cl_kernel") CLKernel kernel, + @PointerWrapper(value = "cl_device_id", canBeNull = true) CLKernel device, + @NativeType("cl_kernel_work_group_info") int param_name, + @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size, + @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);") + @cl_int + int clEnqueueNDRangeKernel(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @PointerWrapper("cl_kernel") CLKernel kernel, + @cl_uint int work_dim, + @Check(value = "work_dim", canBeNull = true) @Const @NativeType("size_t") PointerBuffer global_work_offset, + @Check(value = "work_dim", canBeNull = true) @Const @NativeType("size_t") PointerBuffer global_work_size, + @Check(value = "work_dim", canBeNull = true) @Const @NativeType("size_t") PointerBuffer local_work_size, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);") + @cl_int + int clEnqueueTask(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @PointerWrapper("cl_kernel") CLKernel kernel, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + /** + * Enqueues a native kernel to the specified command queue. The mem_list parameter + * can be used to pass a list of CLMem objects that will be mapped to global memory space and + * exposed as a ByteBuffer array in the CLNativeKernel#execute method. The + * sizes parameter will be used to allocate direct ByteBuffers with the correct + * capacities. The user is responsible for passing appropriate values to avoid crashes. + * + * @param command_queue the command queue + * @param user_func the native kernel + * @param mem_list the CLMem objects + * @param sizes the CLMem object sizes + * @param event_wait_list the event wait list + * @param event the queue event + * + * @return the error code + */ + @Code( + tryBlock = true, + // Build the args buffer and create a GlobalRef to the user_func object. + javaBeforeNative = "\t\tlong user_func_ref = CallbackUtil.createGlobalRef(user_func);\n" + + "\t\tByteBuffer args = APIUtil.getNativeKernelArgs(user_func_ref, mem_list, sizes);", + // Register CLEvent + javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);", + // Check if we need to delete the GlobalRef. + javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_func_ref);", + nativeAfterVars = "\tvoid **args_mem_loc = num_mem_objects == 0 ? NULL : (void **)malloc(num_mem_objects * sizeof(void *));", + nativeBeforeCall = "\t_ptr_i = 0;\n" + + "\twhile ( _ptr_i < num_mem_objects ) {\n" + + "\t\targs_mem_loc[_ptr_i] = (cl_void *)((char *)args_address + (4 + _ptr_i * (4 + sizeof(size_t))));\n" + + "\t\t_ptr_i++;\n" + + "\t}", + nativeAfterCall = "\tfree(args_mem_loc);" + ) + @cl_int + int clEnqueueNativeKernel(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @PointerWrapper("cl_native_kernel_func") CLNativeKernel user_func, + @Constant("args, 0") @cl_void ByteBuffer args, + @AutoSize("args") @size_t long cb_args, + @Constant("mem_list == null ? 0 : mem_list.length") @cl_uint int num_mem_objects, + @Check(value = "1", canBeNull = true) @PointerArray("num_mem_objects") @Const @NativeType("cl_mem") CLMem[] mem_list, + @Check(value = "mem_list.length", canBeNull = true) @Helper long[] sizes, + @Constant(value = "(const void**)args_mem_loc", isNative = true) @Const @Indirect @cl_void ByteBuffer args_mem_loc, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @cl_int + int clWaitForEvents(@AutoSize("event_list") @cl_uint int num_events, @Check("1") @Const @NativeType("cl_event") PointerBuffer event_list); + + @cl_int + int clGetEventInfo(@PointerWrapper("cl_event") CLEvent event, + @NativeType("cl_event_info") int param_name, + @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size, + @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) event.retain();") + @cl_int + int clRetainEvent(@PointerWrapper("cl_event") CLEvent event); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) event.release();") + @cl_int + int clReleaseEvent(@PointerWrapper("cl_event") CLEvent event); + + @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);") + @cl_int + int clEnqueueMarker(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @OutParameter @Check("1") @NativeType("cl_event") PointerBuffer event); + + @cl_int + int clEnqueueBarrier(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue); + + @cl_int + int clEnqueueWaitForEvents(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @AutoSize("event_list") @cl_uint int num_events, + @Check("1") @Const @NativeType("cl_event") PointerBuffer event_list); + + @Alternate("clEnqueueWaitForEvents") + @cl_int + int clEnqueueWaitForEvents(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @Constant("1") @cl_uint int num_events, + @Constant(value = "APIUtil.getBufferPointer().put(0, event).getBuffer(), 0", keepParam = true) CLEvent event); + + @cl_int + int clGetEventProfilingInfo(@PointerWrapper("cl_event") CLEvent event, + @NativeType("cl_profiling_info") int param_name, + @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size, + @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret); + + @cl_int + int clFlush(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue); + + @cl_int + int clFinish(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue); + + @Private + @PointerWrapper("void *") + CLFunctionAddress clGetExtensionFunctionAddress(@Check("1") @Const @cl_char ByteBuffer func_name); + + @Alternate("clGetExtensionFunctionAddress") + @Private + @PointerWrapper("void *") + CLFunctionAddress clGetExtensionFunctionAddress(CharSequence func_name); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/CL10GL.java b/src/templates/org/lwjgl/opencl/CL10GL.java new file mode 100644 index 00000000..bdb49ccf --- /dev/null +++ b/src/templates/org/lwjgl/opencl/CL10GL.java @@ -0,0 +1,138 @@ +/* + * 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.PointerBuffer; +import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opencl.cl_int; +import org.lwjgl.util.generator.opencl.cl_uint; +import org.lwjgl.util.generator.opencl.cl_void; +import org.lwjgl.util.generator.opencl.size_t; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +/** The core OpenCL 1.0 OpenGL interrop functionality. */ +public interface CL10GL { + + /** cl_gl_object_type */ + int CL_GL_OBJECT_BUFFER = 0x2000, + CL_GL_OBJECT_TEXTURE2D = 0x2001, + CL_GL_OBJECT_TEXTURE3D = 0x2002, + CL_GL_OBJECT_RENDERBUFFER = 0x2003; + + /** cl_gl_texture_info */ + int CL_GL_TEXTURE_TARGET = 0x2004, + CL_GL_MIPMAP_LEVEL = 0x2005; + + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_mem", params = "context") + CLMem clCreateFromGLBuffer(@PointerWrapper("cl_context") CLContext context, + @NativeType("cl_mem_flags") long flags, + @NativeType("GLuint") int bufobj, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_mem", params = "context") + CLMem clCreateFromGLTexture2D(@PointerWrapper("cl_context") CLContext context, + @NativeType("cl_mem_flags") long flags, + @NativeType("GLenum") int target, + @NativeType("GLint") int miplevel, + @NativeType("GLuint") int texture, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_mem", params = "context") + CLMem clCreateFromGLTexture3D(@PointerWrapper("cl_context") CLContext context, + @NativeType("cl_mem_flags") long flags, + @NativeType("GLenum") int target, + @NativeType("GLint") int miplevel, + @NativeType("GLuint") int texture, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_mem", params = "context") + CLMem clCreateFromGLRenderbuffer(@PointerWrapper("cl_context") CLContext context, + @NativeType("cl_mem_flags") long flags, + @NativeType("GLuint") int renderbuffer, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @cl_int + int clGetGLObjectInfo(@PointerWrapper("cl_mem") CLMem memobj, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_gl_object_type") IntBuffer gl_object_type, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("GLuint") IntBuffer gl_object_name); + + @cl_int + int clGetGLTextureInfo(@PointerWrapper("cl_mem") CLMem memobj, + @NativeType("cl_gl_texture_info") int param_name, + @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size, + @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret); + + @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) command_queue.registerCLEvent(event);") + @cl_int + int clEnqueueAcquireGLObjects(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @AutoSize("mem_objects") @cl_uint int num_objects, + @Check("1") @Const @NativeType("cl_mem") PointerBuffer mem_objects, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @Alternate("clEnqueueAcquireGLObjects") + @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) command_queue.registerCLEvent(event);") + @cl_int + int clEnqueueAcquireGLObjects(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @Constant("1") @cl_uint int num_objects, + @Constant(value = "APIUtil.getBufferPointer().put(0, mem_object).getBuffer(), 0", keepParam = true) CLMem mem_object, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) command_queue.registerCLEvent(event);") + @cl_int + int clEnqueueReleaseGLObjects(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @AutoSize("mem_objects") @cl_uint int num_objects, + @Check("1") @Const @NativeType("cl_mem") PointerBuffer mem_objects, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @Alternate("clEnqueueReleaseGLObjects") + @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) command_queue.registerCLEvent(event);") + @cl_int + int clEnqueueReleaseGLObjects(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @Constant("1") @cl_uint int num_objects, + @Constant(value = "APIUtil.getBufferPointer().put(0, mem_object).getBuffer(), 0", keepParam = true) CLMem mem_object, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/CL11.java b/src/templates/org/lwjgl/opencl/CL11.java new file mode 100644 index 00000000..dfb35a6e --- /dev/null +++ b/src/templates/org/lwjgl/opencl/CL11.java @@ -0,0 +1,203 @@ +/* + * 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 + * 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.PointerBuffer; +import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opencl.*; + +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +/** The core OpenCL 1.1 API */ +public interface CL11 { + + /** Error Codes */ + int CL_MISALIGNED_SUB_BUFFER_OFFSET = -13, + CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST = -14, + CL_INVALID_PROPERTY = -64; + + /** OpenCL Version */ + int CL_VERSION_1_1 = 1; + + /** cl_device_info */ + int CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF = 0x1034, + CL_DEVICE_HOST_UNIFIED_MEMORY = 0x1035, + CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR = 0x1036, + CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT = 0x1037, + CL_DEVICE_NATIVE_VECTOR_WIDTH_INT = 0x1038, + CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG = 0x1039, + CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT = 0x103A, + CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE = 0x103B, + CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF = 0x103C, + CL_DEVICE_OPENCL_C_VERSION = 0x103D; + + /** cl_device_fp_config - bitfield */ + int CL_FP_SOFT_FLOAT = (1 << 6); + + /** cl_context_info */ + int CL_CONTEXT_NUM_DEVICES = 0x1083; + + /** cl_channel_order */ + int CL_Rx = 0x10BA, + CL_RGx = 0x10BB, + CL_RGBx = 0x10BC; + + /** cl_mem_info */ + int CL_MEM_ASSOCIATED_MEMOBJECT = 0x1107, + CL_MEM_OFFSET = 0x1108; + + /** cl_addressing_mode */ + int CL_ADDRESS_MIRRORED_REPEAT = 0x1134; + + /** cl_kernel_work_group_info */ + int CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE = 0x11B3, + CL_KERNEL_PRIVATE_MEM_SIZE = 0x11B4; + + /** cl_event_info */ + int CL_EVENT_CONTEXT = 0x11D4; + + /** cl_command_type */ + int CL_COMMAND_READ_BUFFER_RECT = 0x1201, + CL_COMMAND_WRITE_BUFFER_RECT = 0x1202, + CL_COMMAND_COPY_BUFFER_RECT = 0x1203, + CL_COMMAND_USER = 0x1204; + + /** cl_buffer_create_type */ + int CL_BUFFER_CREATE_TYPE_REGION = 0x1220; + + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_mem", factory = "CLMem.create", params = "buffer.getParent()") + CLMem clCreateSubBuffer(@PointerWrapper("cl_mem") CLMem buffer, + @NativeType("cl_mem_flags") long flags, + @NativeType("cl_buffer_create_type") int buffer_create_type, + @Const @Check("2 * PointerBuffer.getPointerSize()") @NativeType("cl_void") ByteBuffer buffer_create_info, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Code( + tryBlock = true, + // Create a GlobalRef to the callback object. + javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);", + // Check if we need to delete the GlobalRef. + javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);" + ) + @cl_int + int clSetMemObjectDestructorCallback(@PointerWrapper("cl_mem") CLMem memobj, + @PointerWrapper("cl_mem_object_destructor_callback") CLMemObjectDestructorCallback pfn_notify, + @Constant("user_data") @PointerWrapper("void *") long user_data); + + @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) command_queue.registerCLEvent(event);") + @cl_int + int clEnqueueReadBufferRect(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @PointerWrapper("cl_mem") CLMem buffer, + @cl_bool int blocking_read, + @Const @Check("3") @NativeType("size_t") PointerBuffer buffer_origin, + @Const @Check("3") @NativeType("size_t") PointerBuffer host_origin, + @Const @Check("3") @NativeType("size_t") PointerBuffer region, + @size_t long buffer_row_pitch, + @size_t long buffer_slice_pitch, + @size_t long host_row_pitch, + @size_t long host_slice_pitch, + @OutParameter @Check("CLChecks.calculateBufferRectSize(host_origin, region, host_row_pitch, host_slice_pitch)") + @cl_byte + @cl_short + @cl_int + @cl_long + @cl_float + @cl_double Buffer ptr, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Const @Check(canBeNull = true) @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) command_queue.registerCLEvent(event);") + @cl_int + int clEnqueueWriteBufferRect(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @PointerWrapper("cl_mem") CLMem buffer, + @cl_bool int blocking_write, + @Const @Check("3") @NativeType("size_t") PointerBuffer buffer_origin, + @Const @Check("3") @NativeType("size_t") PointerBuffer host_origin, + @Const @Check("3") @NativeType("size_t") PointerBuffer region, + @size_t long buffer_row_pitch, + @size_t long buffer_slice_pitch, + @size_t long host_row_pitch, + @size_t long host_slice_pitch, + @Const @Check("CLChecks.calculateBufferRectSize(host_origin, region, host_row_pitch, host_slice_pitch)") + @cl_byte + @cl_short + @cl_int + @cl_long + @cl_float + @cl_double Buffer ptr, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Const @Check(canBeNull = true) @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) command_queue.registerCLEvent(event);") + @cl_int + int clEnqueueCopyBufferRect(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @PointerWrapper("cl_mem") CLMem src_buffer, + @PointerWrapper("cl_mem") CLMem dst_buffer, + @Const @Check("3") @NativeType("size_t") PointerBuffer src_origin, + @Const @Check("3") @NativeType("size_t") PointerBuffer dst_origin, + @Const @Check("3") @NativeType("size_t") PointerBuffer region, + @size_t long src_row_pitch, + @size_t long src_slice_pitch, + @size_t long dst_row_pitch, + @size_t long dst_slice_pitch, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Const @Check(canBeNull = true) @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_event", params = "context") + CLEvent clCreateUserEvent(@PointerWrapper("cl_context") CLContext context, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @cl_int + int clSetUserEventStatus(@PointerWrapper("cl_event") CLEvent event, + @cl_int int execution_status); + + @Code( + tryBlock = true, + // Create a GlobalRef to the callback object. + javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);", + // Check if we need to delete the GlobalRef. + javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);" + ) + @cl_int + int clSetEventCallback(@PointerWrapper("cl_event") CLEvent event, + @cl_int int command_exec_callback_type, + @PointerWrapper("cl_event_callback") CLEventCallback pfn_notify, + @Constant("user_data") @PointerWrapper("void *") long user_data); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/EXT_device_fission.java b/src/templates/org/lwjgl/opencl/EXT_device_fission.java new file mode 100644 index 00000000..23ecd9be --- /dev/null +++ b/src/templates/org/lwjgl/opencl/EXT_device_fission.java @@ -0,0 +1,144 @@ +/* + * 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.PointerBuffer; +import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opencl.CLDeviceExtension; +import org.lwjgl.util.generator.opencl.cl_int; +import org.lwjgl.util.generator.opencl.cl_uint; + +import java.nio.IntBuffer; +import java.nio.LongBuffer; + +@CLDeviceExtension +public interface EXT_device_fission { + + /** + * Accepted as a property name in the <properties> parameter of + * clCreateSubDeviceEXT: + */ + int CL_DEVICE_PARTITION_EQUALLY_EXT = 0x4050, + CL_DEVICE_PARTITION_BY_COUNTS_EXT = 0x4051, + CL_DEVICE_PARTITION_BY_NAMES_EXT = 0x4052, + CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT = 0x4053; + + /** + * Accepted as a property name, when accompanying the + * CL_DEVICE_PARITION_BY_AFFINITY_DOMAIN_EXT property, in the <properties> + * parameter of clCreateSubDeviceEXT: + */ + int CL_AFFINITY_DOMAIN_L1_CACHE_EXT = 0x1, + CL_AFFINITY_DOMAIN_L2_CACHE_EXT = 0x2, + CL_AFFINITY_DOMAIN_L3_CACHE_EXT = 0x3, + CL_AFFINITY_DOMAIN_L4_CACHE_EXT = 0x4, + CL_AFFINITY_DOMAIN_NUMA_EXT = 0x10, + CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT = 0x100; + + /** + * Accepted as a property being queried in the <param_name> argument of + * clGetDeviceInfo: + */ + int CL_DEVICE_PARENT_DEVICE_EXT = 0x4054, + CL_DEVICE_PARITION_TYPES_EXT = 0x4055, + CL_DEVICE_AFFINITY_DOMAINS_EXT = 0x4056, + CL_DEVICE_REFERENCE_COUNT_EXT = 0x4057, + CL_DEVICE_PARTITION_STYLE_EXT = 0x4058; + + /** + * Accepted as the property list terminator in the <properties> parameter of + * clCreateSubDeviceEXT: + */ + int CL_PROPERTIES_LIST_END_EXT = 0x0; + + /** + * Accepted as the partition counts list terminator in the <properties> + * parameter of clCreateSubDeviceEXT: + */ + int CL_PARTITION_BY_COUNTS_LIST_END_EXT = 0x0; + + /** + * Accepted as the partition names list terminator in the <properties> + * parameter of clCreateSubDeviceEXT: + */ + int CL_PARTITION_BY_NAMES_LIST_END_EXT = -1; + + /** + * Returned by clCreateSubDevicesEXT when the indicated partition scheme is + * supported by the implementation, but the implementation can not further + * partition the device in this way. + */ + int CL_DEVICE_PARTITION_FAILED_EXT = -1057; + + /** + * Returned by clCreateSubDevicesEXT when the total number of compute units + * requested exceeds CL_DEVICE_MAX_COMPUTE_UNITS, or the number of compute + * units for any one sub-device is less than 1. + */ + int CL_INVALID_PARTITION_COUNT_EXT = -1058; + + /** + * Returned by clCreateSubDevicesEXT when a compute unit name appearing in a + * name list following CL_DEVICE_PARTITION_BY_NAMES_EXT is not in range. + */ + int CL_INVALID_PARTITION_NAME_EXT = -1059; + + @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) device.retain();") + @cl_int + int clRetainDeviceEXT(@PointerWrapper("cl_device_id") CLDevice device); + + /** + * Warning: LWJGL will not automatically release any objects associated with sub-devices. + * The user is responsible for tracking and releasing everything prior to calling this method. + * + * @param device the parent CLDevice + * + * @return the error code + */ + @Code( + javaBeforeNative = "\t\tAPIUtil.releaseObjects(device);", + javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) device.release();" + ) + @cl_int + int clReleaseDeviceEXT(@PointerWrapper("cl_device_id") CLDevice device); + + @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS && out_devices != null ) in_device.registerSubCLDevices(out_devices);") + @cl_int + int clCreateSubDevicesEXT( + @PointerWrapper("cl_device_id") CLDevice in_device, + // TODO: cl_device_partition_property_ext is a cl_bitfield (ulong), but the spec says properties is a {property-value, cl_int[]} list... + @NullTerminated @Const @NativeType("cl_device_partition_property_ext") LongBuffer properties, + @AutoSize(value = "out_devices", canBeNull = true) @cl_uint int num_entries, + @OutParameter @Check(canBeNull = true) @NativeType("cl_device_id") PointerBuffer out_devices, + @OutParameter @Check(value = "1", canBeNull = true) @cl_uint IntBuffer num_devices); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/EXT_migrate_memobject.java b/src/templates/org/lwjgl/opencl/EXT_migrate_memobject.java new file mode 100644 index 00000000..ac4b2808 --- /dev/null +++ b/src/templates/org/lwjgl/opencl/EXT_migrate_memobject.java @@ -0,0 +1,77 @@ +/* + * 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.PointerBuffer; +import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opencl.CLDeviceExtension; +import org.lwjgl.util.generator.opencl.cl_bitfield; +import org.lwjgl.util.generator.opencl.cl_int; +import org.lwjgl.util.generator.opencl.cl_uint; + +@CLDeviceExtension +public interface EXT_migrate_memobject { + + /** + * Besides a value of zero, the following cl_mem_migration_flags_ext values are + * allowed: + */ + int CL_MIGRATE_MEM_OBJECT_HOST_EXT = 0x1; + + /** + * Returned in the <param_value> parameter of the clGetEventInfo when + * <param_name> is CL_EVENT_COMMAND_TYPE: + */ + int CL_COMMAND_MIGRATE_MEM_OBJECT_EXT = 0x4040; + + @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) command_queue.registerCLEvent(event);") + @cl_int + int clEnqueueMigrateMemObjectEXT(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @AutoSize("mem_objects") @cl_uint int num_mem_objects, + @Check("1") @Const @NativeType("cl_mem") PointerBuffer mem_objects, + @cl_bitfield @NativeType("cl_mem_migration_flags_ext") long flags, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @Alternate("clEnqueueMigrateMemObjectEXT") + @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) command_queue.registerCLEvent(event);") + @cl_int + int clEnqueueMigrateMemObjectEXT(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @Constant("1") @cl_uint int num_mem_objects, + @Constant(value = "APIUtil.getBufferPointer().put(0, mem_object).getBuffer(), 0", keepParam = true) CLMem mem_object, + @cl_bitfield @NativeType("cl_mem_migration_flags_ext") long flags, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/KHR_3d_image_writes.java b/src/templates/org/lwjgl/opencl/KHR_3d_image_writes.java new file mode 100644 index 00000000..9585071a --- /dev/null +++ b/src/templates/org/lwjgl/opencl/KHR_3d_image_writes.java @@ -0,0 +1,39 @@ +/* + * 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.util.generator.opencl.CLDeviceExtension; + +@CLDeviceExtension +public interface KHR_3d_image_writes { + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/KHR_byte_addressable_store.java b/src/templates/org/lwjgl/opencl/KHR_byte_addressable_store.java new file mode 100644 index 00000000..191c3c7e --- /dev/null +++ b/src/templates/org/lwjgl/opencl/KHR_byte_addressable_store.java @@ -0,0 +1,39 @@ +/* + * 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.util.generator.opencl.CLDeviceExtension; + +@CLDeviceExtension +public interface KHR_byte_addressable_store { + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/KHR_fp16.java b/src/templates/org/lwjgl/opencl/KHR_fp16.java new file mode 100644 index 00000000..cb1e7433 --- /dev/null +++ b/src/templates/org/lwjgl/opencl/KHR_fp16.java @@ -0,0 +1,39 @@ +/* + * 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.util.generator.opencl.CLDeviceExtension; + +@CLDeviceExtension +public interface KHR_fp16 { + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/KHR_fp64.java b/src/templates/org/lwjgl/opencl/KHR_fp64.java new file mode 100644 index 00000000..aed45ed4 --- /dev/null +++ b/src/templates/org/lwjgl/opencl/KHR_fp64.java @@ -0,0 +1,42 @@ +/* + * 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.util.generator.opencl.CLDeviceExtension; + +@CLDeviceExtension +public interface KHR_fp64 { + + /** cl_device_info */ + int CL_DEVICE_DOUBLE_FP_CONFIG = 0x1032; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/KHR_gl_event.java b/src/templates/org/lwjgl/opencl/KHR_gl_event.java new file mode 100644 index 00000000..ddf6bd0d --- /dev/null +++ b/src/templates/org/lwjgl/opencl/KHR_gl_event.java @@ -0,0 +1,56 @@ +/* + * 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.opengl.GLSync; +import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opencl.CLDeviceExtension; +import org.lwjgl.util.generator.opencl.CLPlatformExtension; +import org.lwjgl.util.generator.opencl.cl_int; + +import java.nio.IntBuffer; + +@Imports("org.lwjgl.opengl.GLSync") +@CLPlatformExtension +@CLDeviceExtension +@Extension(postfix = "KHR", className = "KHRGLEvent") +public interface KHR_gl_event { + + /** Returned by clGetEventInfo when param_name is CL_EVENT_COMMAND_TYPE: */ + int CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR = 0x200D; + + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_event", params = "context") + CLEvent clCreateEventFromGLsyncKHR(@PointerWrapper("cl_context") CLContext context, + @PointerWrapper("cl_GLsync") GLSync sync, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/KHR_gl_sharing.java b/src/templates/org/lwjgl/opencl/KHR_gl_sharing.java new file mode 100644 index 00000000..332d0779 --- /dev/null +++ b/src/templates/org/lwjgl/opencl/KHR_gl_sharing.java @@ -0,0 +1,73 @@ +/* + * 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.PointerBuffer; +import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opencl.*; + +import java.nio.ByteBuffer; + +@CLPlatformExtension +@CLDeviceExtension +@Extension(postfix = "KHR", className = "KHRGLSharing") +public interface KHR_gl_sharing { + + /** + * Returned by clCreateContext, clCreateContextFromType, and + * clGetGLContextInfoKHR when an invalid OpenGL context or share group + * object handle is specified in <properties>: + */ + int CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR = -1000; + + /** Accepted as the <param_name> argument of clGetGLContextInfoKHR: */ + int CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR = 0x2006, + CL_DEVICES_FOR_GL_CONTEXT_KHR = 0x2007; + + /** + * Accepted as an attribute name in the 'properties' argument of + * clCreateContext and clCreateContextFromType: + */ + int CL_GL_CONTEXT_KHR = 0x2008, + CL_EGL_DISPLAY_KHR = 0x2009, + CL_GLX_DISPLAY_KHR = 0x200A, + CL_WGL_HDC_KHR = 0x200B, + CL_CGL_SHAREGROUP_KHR = 0x200C; + + @cl_int + int clGetGLContextInfoKHR(@NullTerminated @Const @NativeType("cl_context_properties") PointerBuffer properties, + @NativeType("cl_gl_context_info") int param_name, + @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size, + @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/KHR_global_int32_base_atomics.java b/src/templates/org/lwjgl/opencl/KHR_global_int32_base_atomics.java new file mode 100644 index 00000000..73ed951b --- /dev/null +++ b/src/templates/org/lwjgl/opencl/KHR_global_int32_base_atomics.java @@ -0,0 +1,39 @@ +/* + * 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.util.generator.opencl.CLDeviceExtension; + +@CLDeviceExtension +public interface KHR_global_int32_base_atomics { + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/KHR_global_int32_extended_atomics.java b/src/templates/org/lwjgl/opencl/KHR_global_int32_extended_atomics.java new file mode 100644 index 00000000..022d2e51 --- /dev/null +++ b/src/templates/org/lwjgl/opencl/KHR_global_int32_extended_atomics.java @@ -0,0 +1,39 @@ +/* + * 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.util.generator.opencl.CLDeviceExtension; + +@CLDeviceExtension +public interface KHR_global_int32_extended_atomics { + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/KHR_icd.java b/src/templates/org/lwjgl/opencl/KHR_icd.java new file mode 100644 index 00000000..fe233e44 --- /dev/null +++ b/src/templates/org/lwjgl/opencl/KHR_icd.java @@ -0,0 +1,57 @@ +/* + * 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.PointerBuffer; +import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opencl.CLPlatformExtension; +import org.lwjgl.util.generator.opencl.cl_int; +import org.lwjgl.util.generator.opencl.cl_uint; + +import java.nio.IntBuffer; + +@CLPlatformExtension +@Extension(postfix = "KHR", className = "KHRICD") +public interface KHR_icd { + + /** Accepted as <param_name> to the function clGetPlatformInfo */ + int CL_PLATFORM_ICD_SUFFIX_KHR = 0x0920; + + /** Returned by clGetPlatformIDs when no platforms are found */ + int CL_PLATFORM_NOT_FOUND_KHR = -1001; + + @cl_int + int clIcdGetPlatformIDsKHR(@AutoSize(value = "platforms", canBeNull = true) @cl_uint int num_entries, + @OutParameter @Check(canBeNull = true) @NativeType("cl_platform_id") PointerBuffer platforms, + @OutParameter @Check(value = "1", canBeNull = true) @cl_uint IntBuffer num_platforms); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/KHR_int64_base_atomics.java b/src/templates/org/lwjgl/opencl/KHR_int64_base_atomics.java new file mode 100644 index 00000000..490d35b1 --- /dev/null +++ b/src/templates/org/lwjgl/opencl/KHR_int64_base_atomics.java @@ -0,0 +1,39 @@ +/* + * 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.util.generator.opencl.CLDeviceExtension; + +@CLDeviceExtension +public interface KHR_int64_base_atomics { + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/KHR_int64_extended_atomics.java b/src/templates/org/lwjgl/opencl/KHR_int64_extended_atomics.java new file mode 100644 index 00000000..e396a5cc --- /dev/null +++ b/src/templates/org/lwjgl/opencl/KHR_int64_extended_atomics.java @@ -0,0 +1,39 @@ +/* + * 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.util.generator.opencl.CLDeviceExtension; + +@CLDeviceExtension +public interface KHR_int64_extended_atomics { + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/KHR_local_int32_base_atomics.java b/src/templates/org/lwjgl/opencl/KHR_local_int32_base_atomics.java new file mode 100644 index 00000000..c18e2a46 --- /dev/null +++ b/src/templates/org/lwjgl/opencl/KHR_local_int32_base_atomics.java @@ -0,0 +1,39 @@ +/* + * 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.util.generator.opencl.CLDeviceExtension; + +@CLDeviceExtension +public interface KHR_local_int32_base_atomics { + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/KHR_local_int32_extended_atomics.java b/src/templates/org/lwjgl/opencl/KHR_local_int32_extended_atomics.java new file mode 100644 index 00000000..e72d86ff --- /dev/null +++ b/src/templates/org/lwjgl/opencl/KHR_local_int32_extended_atomics.java @@ -0,0 +1,39 @@ +/* + * 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.util.generator.opencl.CLDeviceExtension; + +@CLDeviceExtension +public interface KHR_local_int32_extended_atomics { + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/AMD_debug_output.java b/src/templates/org/lwjgl/opengl/AMD_debug_output.java index 662612b0..3a73b879 100644 --- a/src/templates/org/lwjgl/opengl/AMD_debug_output.java +++ b/src/templates/org/lwjgl/opengl/AMD_debug_output.java @@ -32,6 +32,10 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.PointerWrapper; +import org.lwjgl.util.generator.Alias; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.ByteBuffer; import java.nio.IntBuffer; @@ -77,15 +81,16 @@ public interface AMD_debug_output { * The {@code AMDDebugOutputCallback.Handler} implementation passed to this method will be used for * AMD_debug_output messages. If callback is null, any previously registered handler for the current * thread will be unregistered and stop receiving messages. - *

- * The userParam buffer will be passed to the GL, but the current implementation will ignore it and - * never return it to the handler. Instead, users are encouraged to use a custom callback handler - * implentation to store context-specific data. * * @param callback the callback function to use - * @param userParam the user-specified data */ - void glDebugMessageCallbackAMD(@GLpointer(value = "GLDEBUGPROCAMD", canBeNull = true) AMDDebugOutputCallback callback, @Check(canBeNull = true) @GLvoid ByteBuffer userParam); + @Code( + // Create a GlobalRef to the callback object and register it with the current context. + javaBeforeNative = "\t\tlong userParam = callback == null ? 0 : CallbackUtil.createGlobalRef(callback.getHandler());\n" + + "\t\tCallbackUtil.registerContextCallbackAMD(userParam);" + ) + void glDebugMessageCallbackAMD(@PointerWrapper(value = "GLDEBUGPROCAMD", canBeNull = true) AMDDebugOutputCallback callback, + @Constant("userParam") @PointerWrapper("GLvoid *") long userParam); @GLuint int glGetDebugMessageLogAMD(@GLuint int count, diff --git a/src/templates/org/lwjgl/opengl/AMD_draw_buffers_blend.java b/src/templates/org/lwjgl/opengl/AMD_draw_buffers_blend.java index 9786cfa3..a7b1558f 100644 --- a/src/templates/org/lwjgl/opengl/AMD_draw_buffers_blend.java +++ b/src/templates/org/lwjgl/opengl/AMD_draw_buffers_blend.java @@ -31,8 +31,8 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLenum; -import org.lwjgl.util.generator.GLuint; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLuint; public interface AMD_draw_buffers_blend { diff --git a/src/templates/org/lwjgl/opengl/AMD_name_gen_delete.java b/src/templates/org/lwjgl/opengl/AMD_name_gen_delete.java index 89094eab..73f9c670 100644 --- a/src/templates/org/lwjgl/opengl/AMD_name_gen_delete.java +++ b/src/templates/org/lwjgl/opengl/AMD_name_gen_delete.java @@ -32,6 +32,11 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLreturn; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.IntBuffer; @@ -53,7 +58,7 @@ public interface AMD_name_gen_delete { 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 = "APIUtils.getBufferInt().put(0, name), 0", keepParam = true) int name); + void glDeleteNamesAMD(@GLenum int identifier, @Constant("1") @GLsizei int num, @Constant(value = "APIUtil.getBufferInt().put(0, name), 0", keepParam = true) int name); boolean glIsNameAMD(@GLenum int identifier, @GLuint int name); diff --git a/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java b/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java index 3f18a043..9356465d 100644 --- a/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java +++ b/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.ByteBuffer; import java.nio.IntBuffer; @@ -98,12 +100,12 @@ public interface AMD_performance_monitor { void glDeletePerfMonitorsAMD(@AutoSize("monitors") @GLsizei int n, @GLuint IntBuffer monitors); @Alternate("glDeletePerfMonitorsAMD") - void glDeletePerfMonitorsAMD(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, monitor), 0", keepParam = true) int monitor); + void glDeletePerfMonitorsAMD(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, monitor), 0", 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 = "APIUtils.getBufferInt().put(0, counter), 0", keepParam = true) int counter); + void glSelectPerfMonitorCountersAMD(@GLuint int monitor, boolean enable, @GLuint int group, @Constant("1") int numCounters, @Constant(value = "APIUtil.getBufferInt().put(0, counter), 0", keepParam = true) int counter); void glBeginPerfMonitorAMD(@GLuint int monitor); diff --git a/src/templates/org/lwjgl/opengl/AMD_vertex_shader_tessellator.java b/src/templates/org/lwjgl/opengl/AMD_vertex_shader_tessellator.java index 5a596db9..7427a4ca 100644 --- a/src/templates/org/lwjgl/opengl/AMD_vertex_shader_tessellator.java +++ b/src/templates/org/lwjgl/opengl/AMD_vertex_shader_tessellator.java @@ -31,7 +31,7 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLenum; +import org.lwjgl.util.generator.opengl.GLenum; public interface AMD_vertex_shader_tessellator { diff --git a/src/templates/org/lwjgl/opengl/APPLE_element_array.java b/src/templates/org/lwjgl/opengl/APPLE_element_array.java index 8d09178f..29d63d69 100644 --- a/src/templates/org/lwjgl/opengl/APPLE_element_array.java +++ b/src/templates/org/lwjgl/opengl/APPLE_element_array.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.Buffer; import java.nio.IntBuffer; diff --git a/src/templates/org/lwjgl/opengl/APPLE_fence.java b/src/templates/org/lwjgl/opengl/APPLE_fence.java index 073bff7e..c38cd3df 100644 --- a/src/templates/org/lwjgl/opengl/APPLE_fence.java +++ b/src/templates/org/lwjgl/opengl/APPLE_fence.java @@ -32,6 +32,11 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLreturn; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.IntBuffer; @@ -50,7 +55,7 @@ public interface APPLE_fence { void glDeleteFencesAPPLE(@AutoSize("fences") @GLsizei int n, @Const @GLuint IntBuffer fences); @Alternate("glDeleteFencesAPPLE") - void glDeleteFencesAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtils.getBufferInt().put(0, fence), 0", keepParam = true) int fence); + void glDeleteFencesAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtil.getBufferInt().put(0, fence), 0", keepParam = true) int fence); void glSetFenceAPPLE(@GLuint int fence); diff --git a/src/templates/org/lwjgl/opengl/APPLE_flush_buffer_range.java b/src/templates/org/lwjgl/opengl/APPLE_flush_buffer_range.java index 342c7dda..23c902eb 100644 --- a/src/templates/org/lwjgl/opengl/APPLE_flush_buffer_range.java +++ b/src/templates/org/lwjgl/opengl/APPLE_flush_buffer_range.java @@ -31,9 +31,9 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLenum; -import org.lwjgl.util.generator.GLintptr; -import org.lwjgl.util.generator.GLsizeiptr; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLintptr; +import org.lwjgl.util.generator.opengl.GLsizeiptr; public interface APPLE_flush_buffer_range { diff --git a/src/templates/org/lwjgl/opengl/APPLE_object_purgeable.java b/src/templates/org/lwjgl/opengl/APPLE_object_purgeable.java index 87c38477..4cfb1839 100644 --- a/src/templates/org/lwjgl/opengl/APPLE_object_purgeable.java +++ b/src/templates/org/lwjgl/opengl/APPLE_object_purgeable.java @@ -32,6 +32,10 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +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; diff --git a/src/templates/org/lwjgl/opengl/APPLE_texture_range.java b/src/templates/org/lwjgl/opengl/APPLE_texture_range.java index b4dd4caa..5f224628 100644 --- a/src/templates/org/lwjgl/opengl/APPLE_texture_range.java +++ b/src/templates/org/lwjgl/opengl/APPLE_texture_range.java @@ -32,6 +32,9 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLvoid; import java.nio.Buffer; import java.nio.ByteBuffer; diff --git a/src/templates/org/lwjgl/opengl/APPLE_vertex_array_object.java b/src/templates/org/lwjgl/opengl/APPLE_vertex_array_object.java index ea98f2a5..a5254cf3 100644 --- a/src/templates/org/lwjgl/opengl/APPLE_vertex_array_object.java +++ b/src/templates/org/lwjgl/opengl/APPLE_vertex_array_object.java @@ -32,6 +32,10 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.GLreturn; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.IntBuffer; @@ -48,7 +52,7 @@ public interface APPLE_vertex_array_object { void glDeleteVertexArraysAPPLE(@AutoSize("arrays") @GLsizei int n, @Const @GLuint IntBuffer arrays); @Alternate("glDeleteVertexArraysAPPLE") - void glDeleteVertexArraysAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtils.getBufferInt().put(0, array), 0", keepParam = true) int array); + void glDeleteVertexArraysAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtil.getBufferInt().put(0, array), 0", keepParam = true) int array); void glGenVertexArraysAPPLE(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays); diff --git a/src/templates/org/lwjgl/opengl/APPLE_vertex_array_range.java b/src/templates/org/lwjgl/opengl/APPLE_vertex_array_range.java index 2eca4575..37503eb0 100644 --- a/src/templates/org/lwjgl/opengl/APPLE_vertex_array_range.java +++ b/src/templates/org/lwjgl/opengl/APPLE_vertex_array_range.java @@ -32,9 +32,9 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.AutoSize; -import org.lwjgl.util.generator.GLenum; -import org.lwjgl.util.generator.GLsizei; -import org.lwjgl.util.generator.GLvoid; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLvoid; import java.nio.ByteBuffer; diff --git a/src/templates/org/lwjgl/opengl/APPLE_vertex_program_evaluators.java b/src/templates/org/lwjgl/opengl/APPLE_vertex_program_evaluators.java index 77f625d5..a330c2af 100644 --- a/src/templates/org/lwjgl/opengl/APPLE_vertex_program_evaluators.java +++ b/src/templates/org/lwjgl/opengl/APPLE_vertex_program_evaluators.java @@ -33,8 +33,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.Check; import org.lwjgl.util.generator.Const; -import org.lwjgl.util.generator.GLenum; -import org.lwjgl.util.generator.GLuint; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.DoubleBuffer; import java.nio.FloatBuffer; diff --git a/src/templates/org/lwjgl/opengl/ARB_ES2_compatibility.java b/src/templates/org/lwjgl/opengl/ARB_ES2_compatibility.java index 99949f13..e754eeaa 100644 --- a/src/templates/org/lwjgl/opengl/ARB_ES2_compatibility.java +++ b/src/templates/org/lwjgl/opengl/ARB_ES2_compatibility.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.ByteBuffer; import java.nio.IntBuffer; @@ -64,17 +65,22 @@ public interface ARB_ES2_compatibility { GL_MEDIUM_INT = 0x8DF4, GL_HIGH_INT = 0x8DF5; + @Reuse("GL41") void glReleaseShaderCompiler(); + @Reuse("GL41") void glShaderBinary(@AutoSize("shaders") @GLsizei int count, @Const @GLuint IntBuffer shaders, @GLenum int binaryformat, @Const @GLvoid ByteBuffer binary, @AutoSize("binary") @GLsizei int length); + @Reuse("GL41") void glGetShaderPrecisionFormat(@GLenum int shadertype, @GLenum int precisiontype, @OutParameter @Check("2") IntBuffer range, @OutParameter @Check("1") IntBuffer precision); + @Reuse("GL41") void glDepthRangef(@GLclampf float n, @GLclampf float f); + @Reuse("GL41") void glClearDepthf(@GLclampf float d); } \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_blend_func_extended.java b/src/templates/org/lwjgl/opengl/ARB_blend_func_extended.java index ab6b007e..938913f2 100644 --- a/src/templates/org/lwjgl/opengl/ARB_blend_func_extended.java +++ b/src/templates/org/lwjgl/opengl/ARB_blend_func_extended.java @@ -32,6 +32,9 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.GLchar; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.ByteBuffer; @@ -53,13 +56,17 @@ public interface ARB_blend_func_extended { */ int GL_MAX_DUAL_SOURCE_DRAW_BUFFERS = 0x88FC; + @Reuse("GL33") void glBindFragDataLocationIndexed(@GLuint int program, @GLuint int colorNumber, @GLuint int index, @NullTerminated @Const @GLchar ByteBuffer name); + @Reuse("GL33") @Alternate("glBindFragDataLocationIndexed") void glBindFragDataLocationIndexed(@GLuint int program, @GLuint int colorNumber, @GLuint int index, @NullTerminated CharSequence name); + @Reuse("GL33") int glGetFragDataIndex(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name); + @Reuse("GL33") @Alternate("glGetFragDataIndex") int glGetFragDataIndex(@GLuint int program, @NullTerminated CharSequence name); diff --git a/src/templates/org/lwjgl/opengl/ARB_buffer_object.java b/src/templates/org/lwjgl/opengl/ARB_buffer_object.java index 1c627a9c..8106be5a 100644 --- a/src/templates/org/lwjgl/opengl/ARB_buffer_object.java +++ b/src/templates/org/lwjgl/opengl/ARB_buffer_object.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.Buffer; import java.nio.ByteBuffer; @@ -69,7 +71,7 @@ public interface ARB_buffer_object { void glDeleteBuffersARB(@AutoSize("buffers") @GLsizei int n, @Const @GLuint IntBuffer buffers); @Alternate("glDeleteBuffersARB") - void glDeleteBuffersARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer); + void glDeleteBuffersARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer); void glGenBuffersARB(@AutoSize("buffers") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers); @@ -131,7 +133,7 @@ public interface ARB_buffer_object { */ @CachedResult @GLvoid - @AutoResultSize("GLChecks.getBufferObjectSizeARB(caps, target)") + @AutoSize("GLChecks.getBufferObjectSizeARB(caps, target)") ByteBuffer glMapBufferARB(@GLenum int target, @GLenum int access); boolean glUnmapBufferARB(@GLenum int target); @@ -145,6 +147,6 @@ public interface ARB_buffer_object { void glGetBufferParameterivARB2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params); @StripPostfix("pointer") - @AutoResultSize("GLChecks.getBufferObjectSizeARB(caps, target)") + @AutoSize("GLChecks.getBufferObjectSizeARB(caps, target)") void glGetBufferPointervARB(@GLenum int target, @GLenum int pname, @Result @GLvoid ByteBuffer pointer); } diff --git a/src/templates/org/lwjgl/opengl/ARB_cl_event.java b/src/templates/org/lwjgl/opengl/ARB_cl_event.java new file mode 100644 index 00000000..30435fdd --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_cl_event.java @@ -0,0 +1,54 @@ +/* + * 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 + * 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.opencl.CLContext; +import org.lwjgl.opencl.CLEvent; +import org.lwjgl.util.generator.Extension; +import org.lwjgl.util.generator.Imports; +import org.lwjgl.util.generator.PointerWrapper; +import org.lwjgl.util.generator.opengl.GLbitfield; + +@Imports("org.lwjgl.opencl.*") +@Extension(postfix = "ARB", className = "ARBCLEvent") +public interface ARB_cl_event { + + /** Returned in <values> for GetSynciv <pname> OBJECT_TYPE. */ + int GL_SYNC_CL_EVENT_ARB = 0x8240; + + /** Returned in <values> for GetSynciv <pname> SYNC_CONDITION. */ + int GL_SYNC_CL_EVENT_COMPLETE_ARB = 0x8241; + + @PointerWrapper("GLsync") + GLSync glCreateSyncFromCLeventARB(@PointerWrapper("cl_context") CLContext context, @PointerWrapper("cl_event") CLEvent event, @GLbitfield int flags); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_color_buffer_float.java b/src/templates/org/lwjgl/opengl/ARB_color_buffer_float.java index d00de086..6a5bcfdd 100644 --- a/src/templates/org/lwjgl/opengl/ARB_color_buffer_float.java +++ b/src/templates/org/lwjgl/opengl/ARB_color_buffer_float.java @@ -31,7 +31,7 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLenum; +import org.lwjgl.util.generator.opengl.GLenum; public interface ARB_color_buffer_float { diff --git a/src/templates/org/lwjgl/opengl/ARB_copy_buffer.java b/src/templates/org/lwjgl/opengl/ARB_copy_buffer.java index 859f9081..d36b4e94 100644 --- a/src/templates/org/lwjgl/opengl/ARB_copy_buffer.java +++ b/src/templates/org/lwjgl/opengl/ARB_copy_buffer.java @@ -31,9 +31,10 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLenum; -import org.lwjgl.util.generator.GLintptr; -import org.lwjgl.util.generator.GLsizeiptr; +import org.lwjgl.util.generator.Reuse; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLintptr; +import org.lwjgl.util.generator.opengl.GLsizeiptr; public interface ARB_copy_buffer { @@ -47,6 +48,7 @@ public interface ARB_copy_buffer { int GL_COPY_READ_BUFFER = 0x8F36; int GL_COPY_WRITE_BUFFER = 0x8F37; + @Reuse("GL31") void glCopyBufferSubData(@GLenum int readTarget, @GLenum int writeTarget, @GLintptr long readOffset, @GLintptr long writeOffset, @GLsizeiptr long size); diff --git a/src/templates/org/lwjgl/opengl/ARB_debug_output.java b/src/templates/org/lwjgl/opengl/ARB_debug_output.java index 9aa737f4..1189f3e8 100644 --- a/src/templates/org/lwjgl/opengl/ARB_debug_output.java +++ b/src/templates/org/lwjgl/opengl/ARB_debug_output.java @@ -32,6 +32,10 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLchar; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.ByteBuffer; import java.nio.IntBuffer; @@ -103,7 +107,20 @@ public interface ARB_debug_output { @Alternate("glDebugMessageInsertARB") void glDebugMessageInsertARB(@GLenum int source, @GLenum int type, @GLuint int id, @GLenum int severity, @Constant("buf.length()") @GLsizei int length, CharSequence buf); - void glDebugMessageCallbackARB(@GLpointer(value = "GLDEBUGPROCARB", canBeNull = true) ARBDebugOutputCallback callback, @Check(canBeNull = true) @GLvoid ByteBuffer userParam); + /** + * The {@code ARBDebugOutputCallback.Handler} implementation passed to this method will be used for + * ARB_debug_output messages. If callback is null, any previously registered handler for the current + * thread will be unregistered and stop receiving messages. + * + * @param callback the callback function to use + */ + @Code( + // Create a GlobalRef to the callback object and register it with the current context. + javaBeforeNative = "\t\tlong userParam = callback == null ? 0 : CallbackUtil.createGlobalRef(callback.getHandler());\n" + + "\t\tCallbackUtil.registerContextCallbackARB(userParam);" + ) + void glDebugMessageCallbackARB(@PointerWrapper(value = "GLDEBUGPROCARB", canBeNull = true) ARBDebugOutputCallback callback, + @Constant("userParam") @PointerWrapper("GLvoid *") long userParam); @GLuint int glGetDebugMessageLogARB(@GLuint int count, diff --git a/src/templates/org/lwjgl/opengl/ARB_draw_buffers.java b/src/templates/org/lwjgl/opengl/ARB_draw_buffers.java index 8ffbdbb5..f657eb40 100644 --- a/src/templates/org/lwjgl/opengl/ARB_draw_buffers.java +++ b/src/templates/org/lwjgl/opengl/ARB_draw_buffers.java @@ -32,6 +32,9 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLsizei; import java.nio.*; @@ -62,5 +65,5 @@ public interface ARB_draw_buffers { void glDrawBuffersARB(@AutoSize("buffers") @GLsizei int size, @Const @GLenum IntBuffer buffers); @Alternate("glDrawBuffersARB") - void glDrawBuffersARB(@Constant("1") @GLsizei int size, @Constant(value = "APIUtils.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer); + void glDrawBuffersARB(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer); } diff --git a/src/templates/org/lwjgl/opengl/ARB_draw_buffers_blend.java b/src/templates/org/lwjgl/opengl/ARB_draw_buffers_blend.java index d45400c8..afef9e04 100644 --- a/src/templates/org/lwjgl/opengl/ARB_draw_buffers_blend.java +++ b/src/templates/org/lwjgl/opengl/ARB_draw_buffers_blend.java @@ -31,8 +31,8 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLenum; -import org.lwjgl.util.generator.GLuint; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLuint; public interface ARB_draw_buffers_blend { diff --git a/src/templates/org/lwjgl/opengl/ARB_draw_elements_base_vertex.java b/src/templates/org/lwjgl/opengl/ARB_draw_elements_base_vertex.java index 0024d956..2e78dc12 100644 --- a/src/templates/org/lwjgl/opengl/ARB_draw_elements_base_vertex.java +++ b/src/templates/org/lwjgl/opengl/ARB_draw_elements_base_vertex.java @@ -32,11 +32,13 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.Buffer; public interface ARB_draw_elements_base_vertex { + @Reuse("GL32") void glDrawElementsBaseVertex(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type, @BufferObject(BufferKind.ElementVBO) @Const @@ -44,6 +46,7 @@ public interface ARB_draw_elements_base_vertex { @GLushort @GLuint Buffer indices, int basevertex); + @Reuse("GL32") void glDrawRangeElementsBaseVertex(@GLenum int mode, @GLuint int start, @GLuint int end, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type, @BufferObject(BufferKind.ElementVBO) @Const @@ -51,6 +54,7 @@ public interface ARB_draw_elements_base_vertex { @GLushort @GLuint Buffer indices, int basevertex); + @Reuse("GL32") void glDrawElementsInstancedBaseVertex(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type, @BufferObject(BufferKind.ElementVBO) @Const diff --git a/src/templates/org/lwjgl/opengl/ARB_draw_indirect.java b/src/templates/org/lwjgl/opengl/ARB_draw_indirect.java index 86cd3db8..56d9d9d7 100644 --- a/src/templates/org/lwjgl/opengl/ARB_draw_indirect.java +++ b/src/templates/org/lwjgl/opengl/ARB_draw_indirect.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLvoid; import java.nio.IntBuffer; @@ -54,8 +56,10 @@ public interface ARB_draw_indirect { */ int GL_DRAW_INDIRECT_BUFFER_BINDING = 0x8F43; + @Reuse("GL40") void glDrawArraysIndirect(@GLenum int mode, @BufferObject(BufferKind.IndirectBO) @Check("4") @NullTerminated @Const @GLvoid(PrimitiveType.Kind.INT) IntBuffer indirect); + @Reuse("GL40") void glDrawElementsIndirect(@GLenum int mode, @GLenum int type, @BufferObject(BufferKind.IndirectBO) @Check("5") @NullTerminated @Const @GLvoid(PrimitiveType.Kind.INT) IntBuffer indirect); } \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_draw_instanced.java b/src/templates/org/lwjgl/opengl/ARB_draw_instanced.java index 6fba7179..b0f9bbdc 100644 --- a/src/templates/org/lwjgl/opengl/ARB_draw_instanced.java +++ b/src/templates/org/lwjgl/opengl/ARB_draw_instanced.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.Buffer; diff --git a/src/templates/org/lwjgl/opengl/ARB_framebuffer_object.java b/src/templates/org/lwjgl/opengl/ARB_framebuffer_object.java index 51a34f12..74fcae29 100644 --- a/src/templates/org/lwjgl/opengl/ARB_framebuffer_object.java +++ b/src/templates/org/lwjgl/opengl/ARB_framebuffer_object.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.IntBuffer; @@ -184,84 +186,110 @@ public interface ARB_framebuffer_object { /** Accepted by the <value> parameter of GetTexLevelParameter: */ int GL_TEXTURE_STENCIL_SIZE = 0x88F1; + @Reuse("GL30") boolean glIsRenderbuffer(@GLuint int renderbuffer); + @Reuse("GL30") void glBindRenderbuffer(@GLenum int target, @GLuint int renderbuffer); + @Reuse("GL30") void glDeleteRenderbuffers(@AutoSize("renderbuffers") @GLsizei int n, @Const @GLuint IntBuffer renderbuffers); + @Reuse("GL30") @Alternate("glDeleteRenderbuffers") - void glDeleteRenderbuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, renderbuffer), 0", keepParam = true) int renderbuffer); + void glDeleteRenderbuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, renderbuffer), 0", keepParam = true) int renderbuffer); + @Reuse("GL30") void glGenRenderbuffers(@AutoSize("renderbuffers") @GLsizei int n, @OutParameter @GLuint IntBuffer renderbuffers); + @Reuse("GL30") @Alternate("glGenRenderbuffers") @GLreturn("renderbuffers") void glGenRenderbuffers2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer renderbuffers); + @Reuse("GL30") void glRenderbufferStorage(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLsizei int height); + @Reuse("GL30") void glRenderbufferStorageMultisample(@GLenum int target, @GLsizei int samples, @GLenum int internalformat, @GLsizei int width, @GLsizei int height); + @Reuse("GL30") @StripPostfix("params") void glGetRenderbufferParameteriv(@GLenum int target, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + @Reuse("GL30") @Alternate("glGetRenderbufferParameteriv") @GLreturn("params") @StripPostfix("params") void glGetRenderbufferParameteriv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params); + @Reuse("GL30") boolean glIsFramebuffer(@GLuint int framebuffer); + @Reuse("GL30") void glBindFramebuffer(@GLenum int target, @GLuint int framebuffer); + @Reuse("GL30") void glDeleteFramebuffers(@AutoSize("framebuffers") @GLsizei int n, @Const @GLuint IntBuffer framebuffers); + @Reuse("GL30") @Alternate("glDeleteFramebuffers") - void glDeleteFramebuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, framebuffer), 0", keepParam = true) int framebuffer); + void glDeleteFramebuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, framebuffer), 0", keepParam = true) int framebuffer); + @Reuse("GL30") void glGenFramebuffers(@AutoSize("framebuffers") @GLsizei int n, @OutParameter @GLuint IntBuffer framebuffers); + @Reuse("GL30") @Alternate("glGenFramebuffers") @GLreturn("framebuffers") void glGenFramebuffers2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer framebuffers); + @Reuse("GL30") @GLenum int glCheckFramebufferStatus(@GLenum int target); + @Reuse("GL30") void glFramebufferTexture1D(@GLenum int target, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level); + @Reuse("GL30") void glFramebufferTexture2D(@GLenum int target, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level); + @Reuse("GL30") void glFramebufferTexture3D(@GLenum int target, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level, int layer); + @Reuse("GL30") void glFramebufferTextureLayer(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer); + @Reuse("GL30") void glFramebufferRenderbuffer(@GLenum int target, @GLenum int attachment, @GLenum int renderbuffertarget, @GLuint int renderbuffer); + @Reuse("GL30") @StripPostfix("params") void glGetFramebufferAttachmentParameteriv(@GLenum int target, @GLenum int attachment, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + @Reuse("GL30") @Alternate("glGetFramebufferAttachmentParameteriv") @GLreturn("params") @StripPostfix("params") void glGetFramebufferAttachmentParameteriv2(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter IntBuffer params); + @Reuse("GL30") void glBlitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, @GLbitfield int mask, @GLenum int filter); + @Reuse("GL30") void glGenerateMipmap(@GLenum int target); } \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_geometry_shader4.java b/src/templates/org/lwjgl/opengl/ARB_geometry_shader4.java index 286439fb..e385f537 100644 --- a/src/templates/org/lwjgl/opengl/ARB_geometry_shader4.java +++ b/src/templates/org/lwjgl/opengl/ARB_geometry_shader4.java @@ -31,8 +31,8 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLenum; -import org.lwjgl.util.generator.GLuint; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLuint; public interface ARB_geometry_shader4 { diff --git a/src/templates/org/lwjgl/opengl/ARB_get_program_binary.java b/src/templates/org/lwjgl/opengl/ARB_get_program_binary.java index 9bb8e8f2..889eaf9b 100644 --- a/src/templates/org/lwjgl/opengl/ARB_get_program_binary.java +++ b/src/templates/org/lwjgl/opengl/ARB_get_program_binary.java @@ -32,6 +32,10 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; +import org.lwjgl.util.generator.opengl.GLvoid; import java.nio.ByteBuffer; import java.nio.IntBuffer; @@ -54,13 +58,16 @@ public interface ARB_get_program_binary { int GL_NUM_PROGRAM_BINARY_FORMATS = 0x87FE, GL_PROGRAM_BINARY_FORMATS = 0x87FF; + @Reuse("GL41") void glGetProgramBinary(@GLuint int program, @AutoSize("binary") @GLsizei int bufSize, @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, @Check("1") @GLenum IntBuffer binaryFormat, @OutParameter @GLvoid ByteBuffer binary); + @Reuse("GL41") void glProgramBinary(@GLuint int program, @GLenum int binaryFormat, @Const @GLvoid ByteBuffer binary, @AutoSize("binary") @GLsizei int length); + @Reuse("GL41") void glProgramParameteri(@GLuint int program, @GLenum int pname, int value); } \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_gpu_shader_fp64.java b/src/templates/org/lwjgl/opengl/ARB_gpu_shader_fp64.java index 10557d40..c7c8f2a6 100644 --- a/src/templates/org/lwjgl/opengl/ARB_gpu_shader_fp64.java +++ b/src/templates/org/lwjgl/opengl/ARB_gpu_shader_fp64.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.*; @@ -57,53 +59,71 @@ public interface ARB_gpu_shader_fp64 { int GL_DOUBLE_MAT4x2 = 0x8F4D; int GL_DOUBLE_MAT4x3 = 0x8F4E; + @Reuse("GL40") void glUniform1d(int location, double x); + @Reuse("GL40") void glUniform2d(int location, double x, double y); + @Reuse("GL40") void glUniform3d(int location, double x, double y, double z); + @Reuse("GL40") void glUniform4d(int location, double x, double y, double z, double w); + @Reuse("GL40") @StripPostfix("value") void glUniform1dv(int location, @AutoSize("value") @GLsizei int count, @Const DoubleBuffer value); + @Reuse("GL40") @StripPostfix("value") void glUniform2dv(int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const DoubleBuffer value); + @Reuse("GL40") @StripPostfix("value") void glUniform3dv(int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const DoubleBuffer value); + @Reuse("GL40") @StripPostfix("value") void glUniform4dv(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const DoubleBuffer value); + @Reuse("GL40") @StripPostfix("value") void glUniformMatrix2dv(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + @Reuse("GL40") @StripPostfix("value") void glUniformMatrix3dv(int location, @AutoSize(value = "value", expression = " / (3 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + @Reuse("GL40") @StripPostfix("value") void glUniformMatrix4dv(int location, @AutoSize(value = "value", expression = " >> 4") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + @Reuse("GL40") @StripPostfix("value") void glUniformMatrix2x3dv(int location, @AutoSize(value = "value", expression = " / (2 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + @Reuse("GL40") @StripPostfix("value") void glUniformMatrix2x4dv(int location, @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + @Reuse("GL40") @StripPostfix("value") void glUniformMatrix3x2dv(int location, @AutoSize(value = "value", expression = " / (3 * 2)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + @Reuse("GL40") @StripPostfix("value") void glUniformMatrix3x4dv(int location, @AutoSize(value = "value", expression = " / (3 * 4)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + @Reuse("GL40") @StripPostfix("value") void glUniformMatrix4x2dv(int location, @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + @Reuse("GL40") @StripPostfix("value") void glUniformMatrix4x3dv(int location, @AutoSize(value = "value", expression = " / (4 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + @Reuse("GL40") @StripPostfix("params") void glGetUniformdv(@GLuint int program, int location, @OutParameter @Check DoubleBuffer params); diff --git a/src/templates/org/lwjgl/opengl/ARB_imaging.java b/src/templates/org/lwjgl/opengl/ARB_imaging.java index 56a081ed..54ce312a 100644 --- a/src/templates/org/lwjgl/opengl/ARB_imaging.java +++ b/src/templates/org/lwjgl/opengl/ARB_imaging.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; @@ -173,8 +174,10 @@ public interface ARB_imaging { @DeprecatedGL void glGetColorTableParameterfv(@GLenum int target, @GLenum int pname, @Check("4") FloatBuffer params); + @Reuse("GL14") void glBlendEquation(@GLenum int mode); + @Reuse("GL14") void glBlendColor(@GLclampf float red, @GLclampf float green, @GLclampf float blue, @GLclampf float alpha); @DeprecatedGL diff --git a/src/templates/org/lwjgl/opengl/ARB_instanced_arrays.java b/src/templates/org/lwjgl/opengl/ARB_instanced_arrays.java index 24912c6c..a770471a 100644 --- a/src/templates/org/lwjgl/opengl/ARB_instanced_arrays.java +++ b/src/templates/org/lwjgl/opengl/ARB_instanced_arrays.java @@ -31,7 +31,7 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLuint; +import org.lwjgl.util.generator.opengl.GLuint; public interface ARB_instanced_arrays { diff --git a/src/templates/org/lwjgl/opengl/ARB_map_buffer_range.java b/src/templates/org/lwjgl/opengl/ARB_map_buffer_range.java index f99b4bee..dc391505 100644 --- a/src/templates/org/lwjgl/opengl/ARB_map_buffer_range.java +++ b/src/templates/org/lwjgl/opengl/ARB_map_buffer_range.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.ByteBuffer; @@ -59,11 +60,13 @@ public interface ARB_map_buffer_range { * * @return A ByteBuffer representing the mapped buffer memory. */ + @Reuse("GL30") @CachedResult(isRange = true) @GLvoid - @AutoResultSize("length") + @AutoSize("length") ByteBuffer glMapBufferRange(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length, @GLbitfield int access); + @Reuse("GL30") void glFlushMappedBufferRange(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length); } \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_matrix_palette.java b/src/templates/org/lwjgl/opengl/ARB_matrix_palette.java index 18a7a455..f17c934f 100644 --- a/src/templates/org/lwjgl/opengl/ARB_matrix_palette.java +++ b/src/templates/org/lwjgl/opengl/ARB_matrix_palette.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/ARB_multisample.java b/src/templates/org/lwjgl/opengl/ARB_multisample.java index 540580f4..e81f1709 100644 --- a/src/templates/org/lwjgl/opengl/ARB_multisample.java +++ b/src/templates/org/lwjgl/opengl/ARB_multisample.java @@ -31,7 +31,7 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLclampf; public interface ARB_multisample { diff --git a/src/templates/org/lwjgl/opengl/ARB_multitexture.java b/src/templates/org/lwjgl/opengl/ARB_multitexture.java index d34358c5..492a9a75 100644 --- a/src/templates/org/lwjgl/opengl/ARB_multitexture.java +++ b/src/templates/org/lwjgl/opengl/ARB_multitexture.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; public interface ARB_multitexture { diff --git a/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java b/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java index ac6031ff..3973f3b5 100644 --- a/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java +++ b/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java @@ -32,6 +32,11 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLreturn; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.IntBuffer; @@ -63,7 +68,7 @@ public interface ARB_occlusion_query { void glDeleteQueriesARB(@AutoSize("ids") @GLsizei int n, @GLuint IntBuffer ids); @Alternate("glDeleteQueriesARB") - void glDeleteQueriesARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, id), 0", keepParam = true) int id); + void glDeleteQueriesARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, id), 0", keepParam = true) int id); boolean glIsQueryARB(@GLuint int id); diff --git a/src/templates/org/lwjgl/opengl/ARB_point_parameters.java b/src/templates/org/lwjgl/opengl/ARB_point_parameters.java index 59547757..5a6ce3cb 100644 --- a/src/templates/org/lwjgl/opengl/ARB_point_parameters.java +++ b/src/templates/org/lwjgl/opengl/ARB_point_parameters.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/ARB_program.java b/src/templates/org/lwjgl/opengl/ARB_program.java index 4480e461..0616f602 100644 --- a/src/templates/org/lwjgl/opengl/ARB_program.java +++ b/src/templates/org/lwjgl/opengl/ARB_program.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; @@ -126,7 +128,7 @@ public interface ARB_program { void glDeleteProgramsARB(@AutoSize("programs") @GLsizei int n, @Const @GLuint IntBuffer programs); @Alternate("glDeleteProgramsARB") - void glDeleteProgramsARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, program), 0", keepParam = true) int program); + void glDeleteProgramsARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, program), 0", keepParam = true) int program); void glGenProgramsARB(@AutoSize("programs") @GLsizei int n, @OutParameter @GLuint IntBuffer programs); diff --git a/src/templates/org/lwjgl/opengl/ARB_provoking_vertex.java b/src/templates/org/lwjgl/opengl/ARB_provoking_vertex.java index 0bf26e78..0bca11ba 100644 --- a/src/templates/org/lwjgl/opengl/ARB_provoking_vertex.java +++ b/src/templates/org/lwjgl/opengl/ARB_provoking_vertex.java @@ -31,7 +31,8 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLenum; +import org.lwjgl.util.generator.Reuse; +import org.lwjgl.util.generator.opengl.GLenum; public interface ARB_provoking_vertex { @@ -46,6 +47,7 @@ public interface ARB_provoking_vertex { int GL_PROVOKING_VERTEX = 0x8E4F; int GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION = 0x8E4C; + @Reuse("GL32") void glProvokingVertex(@GLenum int mode); } \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_robustness.java b/src/templates/org/lwjgl/opengl/ARB_robustness.java index fe847c41..d44b4385 100644 --- a/src/templates/org/lwjgl/opengl/ARB_robustness.java +++ b/src/templates/org/lwjgl/opengl/ARB_robustness.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/ARB_sample_shading.java b/src/templates/org/lwjgl/opengl/ARB_sample_shading.java index 543ef6c1..4c2ac572 100644 --- a/src/templates/org/lwjgl/opengl/ARB_sample_shading.java +++ b/src/templates/org/lwjgl/opengl/ARB_sample_shading.java @@ -31,7 +31,7 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLclampf; +import org.lwjgl.util.generator.opengl.GLclampf; public interface ARB_sample_shading { diff --git a/src/templates/org/lwjgl/opengl/ARB_sampler_objects.java b/src/templates/org/lwjgl/opengl/ARB_sampler_objects.java index 2ca468cf..1916ef83 100644 --- a/src/templates/org/lwjgl/opengl/ARB_sampler_objects.java +++ b/src/templates/org/lwjgl/opengl/ARB_sampler_objects.java @@ -32,6 +32,11 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLreturn; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.FloatBuffer; import java.nio.IntBuffer; @@ -45,64 +50,84 @@ public interface ARB_sampler_objects { */ int GL_SAMPLER_BINDING = 0x8919; + @Reuse("GL33") void glGenSamplers(@AutoSize("samplers") @GLsizei int count, @OutParameter @GLuint IntBuffer samplers); + @Reuse("GL33") @Alternate("glGenSamplers") @GLreturn("samplers") void glGenSamplers2(@Constant("1") @GLsizei int count, @OutParameter @GLuint IntBuffer samplers); + @Reuse("GL33") void glDeleteSamplers(@AutoSize("samplers") @GLsizei int count, @Const @GLuint IntBuffer samplers); + @Reuse("GL33") @Alternate("glDeleteSamplers") - void glDeleteSamplers(@Constant("1") @GLsizei int count, @Constant(value = "APIUtils.getBufferInt().put(0, sampler), 0", keepParam = true) int sampler); + void glDeleteSamplers(@Constant("1") @GLsizei int count, @Constant(value = "APIUtil.getBufferInt().put(0, sampler), 0", keepParam = true) int sampler); + @Reuse("GL33") boolean glIsSampler(@GLuint int sampler); + @Reuse("GL33") void glBindSampler(@GLenum int unit, @GLuint int sampler); + @Reuse("GL33") void glSamplerParameteri(@GLuint int sampler, @GLenum int pname, int param); + @Reuse("GL33") void glSamplerParameterf(@GLuint int sampler, @GLenum int pname, float param); + @Reuse("GL33") @StripPostfix("params") void glSamplerParameteriv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const IntBuffer params); + @Reuse("GL33") @StripPostfix("params") void glSamplerParameterfv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const FloatBuffer params); + @Reuse("GL33") @StripPostfix("params") void glSamplerParameterIiv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const IntBuffer params); + @Reuse("GL33") @StripPostfix("params") void glSamplerParameterIuiv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const @GLuint IntBuffer params); + @Reuse("GL33") @StripPostfix("params") void glGetSamplerParameteriv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + @Reuse("GL33") @Alternate("glGetSamplerParameteriv") @GLreturn("params") @StripPostfix(value = "params", postfix = "v") void glGetSamplerParameteriv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params); + @Reuse("GL33") @StripPostfix("params") void glGetSamplerParameterfv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter FloatBuffer params); + @Reuse("GL33") @Alternate("glGetSamplerParameterfv") @GLreturn("params") @StripPostfix(value = "params", postfix = "v") void glGetSamplerParameterfv2(@GLuint int sampler, @GLenum int pname, @OutParameter FloatBuffer params); + @Reuse("GL33") @StripPostfix("params") void glGetSamplerParameterIiv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + @Reuse("GL33") @Alternate("glGetSamplerParameterIiv") @GLreturn("params") @StripPostfix(value = "params", postfix = "v") void glGetSamplerParameterIiv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params); + @Reuse("GL33") @StripPostfix("params") void glGetSamplerParameterIuiv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + @Reuse("GL33") @Alternate("glGetSamplerParameterIuiv") @GLreturn("params") @StripPostfix(value = "params", postfix = "v") diff --git a/src/templates/org/lwjgl/opengl/ARB_separate_shader_objects.java b/src/templates/org/lwjgl/opengl/ARB_separate_shader_objects.java index 2d7fe03b..a1853ad7 100644 --- a/src/templates/org/lwjgl/opengl/ARB_separate_shader_objects.java +++ b/src/templates/org/lwjgl/opengl/ARB_separate_shader_objects.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.ByteBuffer; import java.nio.DoubleBuffer; @@ -64,202 +66,269 @@ public interface ARB_separate_shader_objects { */ int GL_PROGRAM_PIPELINE_BINDING = 0x825A; + @Reuse("GL41") void glUseProgramStages(@GLuint int pipeline, @GLbitfield int stages, @GLuint int program); + @Reuse("GL41") void glActiveShaderProgram(@GLuint int pipeline, @GLuint int program); + @Reuse("GL41") @StripPostfix(value = "strings", postfix = "v") @GLuint int glCreateShaderProgramv(@GLenum int type, @GLsizei int count, @Check @Const @Indirect @GLchar ByteBuffer strings); + @Reuse("GL41") @Alternate("glCreateShaderProgramv") @StripPostfix(value = "string", postfix = "v") @GLuint int glCreateShaderProgramv(@GLenum int type, @Constant("1") @GLsizei int count, @NullTerminated CharSequence string); + @Reuse("GL41") @Alternate("glCreateShaderProgramv") @StripPostfix(value = "strings", postfix = "v") @GLuint int glCreateShaderProgramv(@GLenum int type, @Constant("strings.length") @GLsizei int count, - @Const @NullTerminated @StringList(value = "count") CharSequence[] strings); + @Const @NullTerminated @PointerArray(value = "count") CharSequence[] strings); + @Reuse("GL41") void glBindProgramPipeline(@GLuint int pipeline); + @Reuse("GL41") void glDeleteProgramPipelines(@AutoSize("pipelines") @GLsizei int n, @Const @GLuint IntBuffer pipelines); + @Reuse("GL41") @Alternate("glDeleteProgramPipelines") - void glDeleteProgramPipelines(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, pipeline), 0", keepParam = true) int pipeline); + void glDeleteProgramPipelines(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, pipeline), 0", keepParam = true) int pipeline); + @Reuse("GL41") void glGenProgramPipelines(@AutoSize("pipelines") @GLsizei int n, @OutParameter @GLuint IntBuffer pipelines); + @Reuse("GL41") @Alternate("glGenProgramPipelines") @GLreturn("pipelines") void glGenProgramPipelines2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer pipelines); + @Reuse("GL41") boolean glIsProgramPipeline(@GLuint int pipeline); + @Reuse("GL41") void glProgramParameteri(@GLuint int program, @GLenum int pname, int value); + @Reuse("GL41") @StripPostfix("params") void glGetProgramPipelineiv(@GLuint int pipeline, @GLenum int pname, @OutParameter @Check("1") IntBuffer params); + @Reuse("GL41") @Alternate("glGetProgramPipelineiv") @GLreturn("params") @StripPostfix("params") void glGetProgramPipelineiv2(@GLuint int pipeline, @GLenum int pname, @OutParameter IntBuffer params); + @Reuse("GL41") void glProgramUniform1i(@GLuint int program, int location, int v0); + @Reuse("GL41") void glProgramUniform2i(@GLuint int program, int location, int v0, int v1); + @Reuse("GL41") void glProgramUniform3i(@GLuint int program, int location, int v0, int v1, int v2); + @Reuse("GL41") void glProgramUniform4i(@GLuint int program, int location, int v0, int v1, int v2, int v3); + @Reuse("GL41") void glProgramUniform1f(@GLuint int program, int location, float v0); + @Reuse("GL41") void glProgramUniform2f(@GLuint int program, int location, float v0, float v1); + @Reuse("GL41") void glProgramUniform3f(@GLuint int program, int location, float v0, float v1, float v2); + @Reuse("GL41") void glProgramUniform4f(@GLuint int program, int location, float v0, float v1, float v2, float v3); + @Reuse("GL41") void glProgramUniform1d(@GLuint int program, int location, double v0); + @Reuse("GL41") void glProgramUniform2d(@GLuint int program, int location, double v0, double v1); + @Reuse("GL41") void glProgramUniform3d(@GLuint int program, int location, double v0, double v1, double v2); + @Reuse("GL41") void glProgramUniform4d(@GLuint int program, int location, double v0, double v1, double v2, double v3); + @Reuse("GL41") @StripPostfix("value") void glProgramUniform1iv(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const IntBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniform2iv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const IntBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniform3iv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const IntBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniform4iv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const IntBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniform1fv(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const FloatBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniform2fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const FloatBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniform3fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const FloatBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniform4fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const FloatBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniform1dv(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const DoubleBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniform2dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const DoubleBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniform3dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const DoubleBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniform4dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const DoubleBuffer value); + @Reuse("GL41") void glProgramUniform1ui(@GLuint int program, int location, int v0); + @Reuse("GL41") void glProgramUniform2ui(@GLuint int program, int location, int v0, int v1); + @Reuse("GL41") void glProgramUniform3ui(@GLuint int program, int location, int v0, int v1, int v2); + @Reuse("GL41") void glProgramUniform4ui(@GLuint int program, int location, int v0, int v1, int v2, int v3); + @Reuse("GL41") @StripPostfix("value") void glProgramUniform1uiv(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const IntBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniform2uiv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const IntBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniform3uiv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const IntBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniform4uiv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const IntBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniformMatrix2fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniformMatrix3fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (3 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniformMatrix4fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 4") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniformMatrix2dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniformMatrix3dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (3 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniformMatrix4dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 4") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniformMatrix2x3fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (2 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniformMatrix3x2fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (3 * 2)") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniformMatrix2x4fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniformMatrix4x2fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniformMatrix3x4fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (3 * 4)") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniformMatrix4x3fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (4 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniformMatrix2x3dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (2 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniformMatrix3x2dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (3 * 2)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniformMatrix2x4dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniformMatrix4x2dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniformMatrix3x4dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (3 * 4)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + @Reuse("GL41") @StripPostfix("value") void glProgramUniformMatrix4x3dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (4 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + @Reuse("GL41") void glValidateProgramPipeline(@GLuint int pipeline); + @Reuse("GL41") void glGetProgramPipelineInfoLog(@GLuint int pipeline, @AutoSize("infoLog") @GLsizei int bufSize, @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, @OutParameter @GLchar ByteBuffer infoLog); + @Reuse("GL41") @Alternate("glGetProgramPipelineInfoLog") @GLreturn(value = "infoLog", maxLength = "bufSize") void glGetProgramPipelineInfoLog2(@GLuint int pipeline, @GLsizei int bufSize, diff --git a/src/templates/org/lwjgl/opengl/ARB_shader_objects.java b/src/templates/org/lwjgl/opengl/ARB_shader_objects.java index c774b038..dd2003ba 100644 --- a/src/templates/org/lwjgl/opengl/ARB_shader_objects.java +++ b/src/templates/org/lwjgl/opengl/ARB_shader_objects.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.ByteBuffer; import java.nio.FloatBuffer; @@ -107,8 +109,8 @@ public interface ARB_shader_objects { @Alternate(value = "glShaderSourceARB", nativeAlt = true) void glShaderSourceARB3(@GLhandleARB int shader, @Constant("strings.length") @GLsizei int count, - @Const @StringList(value = "count", lengths = "length") CharSequence[] strings, - @Constant("APIUtils.getLengths(strings), 0") @Const IntBuffer length); + @Const @PointerArray(value = "count", lengths = "length") CharSequence[] strings, + @Constant("APIUtil.getLengths(strings), 0") @Const IntBuffer length); void glCompileShaderARB(@GLhandleARB int shaderObj); @@ -232,7 +234,7 @@ public interface ARB_shader_objects { @Alternate(value = "glGetActiveUniformARB", javaAlt = true) @GLreturn(value = "name", maxLength = "maxLength") void glGetActiveUniformARB(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength, - @OutParameter @GLsizei @Constant("name_length, 0, APIUtils.getBufferInt(), 0, APIUtils.getBufferInt(), 1") IntBuffer length, + @OutParameter @GLsizei @Constant("name_length, 0, APIUtil.getBufferInt(), 0, APIUtil.getBufferInt(), 1") IntBuffer length, @OutParameter @GLcharARB ByteBuffer name); /** Overloads glGetActiveUniformARB. This version returns only the uniform size. */ @@ -242,7 +244,7 @@ public interface ARB_shader_objects { @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, @OutParameter IntBuffer size, @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore - @OutParameter @GLcharARB @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name); + @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name); /** Overloads glGetActiveUniformARB. This version returns only the uniform type. */ @Alternate(value = "glGetActiveUniformARB", javaAlt = true) @@ -251,7 +253,7 @@ public interface ARB_shader_objects { @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore @OutParameter @GLenum IntBuffer type, - @OutParameter @GLcharARB @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name); + @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name); @StripPostfix("params") void glGetUniformfvARB(@GLhandleARB int programObj, int location, @OutParameter @Check FloatBuffer params); diff --git a/src/templates/org/lwjgl/opengl/ARB_shader_subroutine.java b/src/templates/org/lwjgl/opengl/ARB_shader_subroutine.java index 51d1b6b7..6f383d64 100644 --- a/src/templates/org/lwjgl/opengl/ARB_shader_subroutine.java +++ b/src/templates/org/lwjgl/opengl/ARB_shader_subroutine.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.ByteBuffer; import java.nio.IntBuffer; @@ -59,55 +61,68 @@ public interface ARB_shader_subroutine { int GL_UNIFORM_SIZE = GL31.GL_UNIFORM_SIZE; int GL_UNIFORM_NAME_LENGTH = GL31.GL_UNIFORM_NAME_LENGTH; + @Reuse("GL40") int glGetSubroutineUniformLocation(@GLuint int program, @GLenum int shadertype, @Const @NullTerminated ByteBuffer name); + @Reuse("GL40") @GLuint int glGetSubroutineIndex(@GLuint int program, @GLenum int shadertype, @Const @NullTerminated ByteBuffer name); + @Reuse("GL40") @StripPostfix("values") void glGetActiveSubroutineUniformiv(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLenum int pname, @Check("1") @OutParameter IntBuffer values); + @Reuse("GL40") @Alternate("glGetActiveSubroutineUniformiv") @GLreturn("values") @StripPostfix("values") void glGetActiveSubroutineUniformiv2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLenum int pname, @OutParameter IntBuffer values); + @Reuse("GL40") void glGetActiveSubroutineUniformName(@GLuint int program, @GLenum int shadertype, @GLuint int index, @AutoSize("name") @GLsizei int bufsize, @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, @OutParameter ByteBuffer name); + @Reuse("GL40") @Alternate("glGetActiveSubroutineUniformName") @GLreturn(value = "name", maxLength = "bufsize") void glGetActiveSubroutineUniformName2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLsizei int bufsize, @OutParameter @Constant("name_length, 0") @GLsizei IntBuffer length, @OutParameter @GLchar ByteBuffer name); + @Reuse("GL40") void glGetActiveSubroutineName(@GLuint int program, @GLenum int shadertype, @GLuint int index, @AutoSize("name") @GLsizei int bufsize, @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, @OutParameter ByteBuffer name); + @Reuse("GL40") @Alternate("glGetActiveSubroutineName") @GLreturn(value = "name", maxLength = "bufsize") void glGetActiveSubroutineName2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLsizei int bufsize, @OutParameter @Constant("name_length, 0") @GLsizei IntBuffer length, @OutParameter @GLchar ByteBuffer name); + @Reuse("GL40") @StripPostfix("indices") void glUniformSubroutinesuiv(@GLenum int shadertype, @AutoSize("indices") @GLsizei int count, @Const @GLuint IntBuffer indices); + @Reuse("GL40") @StripPostfix("params") void glGetUniformSubroutineuiv(@GLenum int shadertype, int location, @Check("1") @OutParameter @GLuint IntBuffer params); + @Reuse("GL40") @Alternate("glGetUniformSubroutineuiv") @GLreturn("params") @StripPostfix("params") void glGetUniformSubroutineuiv2(@GLenum int shadertype, int location, @OutParameter @GLuint IntBuffer params); + @Reuse("GL40") @StripPostfix("values") void glGetProgramStageiv(@GLuint int program, @GLenum int shadertype, @GLenum int pname, @Check("1") @OutParameter IntBuffer values); + @Reuse("GL40") @Alternate("glGetProgramStageiv") @GLreturn("values") @StripPostfix("values") diff --git a/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java b/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java index 482411aa..64ab50d2 100644 --- a/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java +++ b/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.ByteBuffer; import java.nio.IntBuffer; @@ -60,13 +62,13 @@ public interface ARB_shading_language_include { void glDeleteNamedStringARB(@Constant("name.length()") int namelen, CharSequence name); void glCompileShaderIncludeARB(@GLuint int shader, @GLsizei int count, - @Const @NullTerminated("count") @StringList("count") @GLchar ByteBuffer path, + @Const @NullTerminated("count") @PointerArray("count") @GLchar ByteBuffer path, @Constant("null, 0") @Const IntBuffer length); @Alternate(value = "glCompileShaderIncludeARB", nativeAlt = true) void glCompileShaderIncludeARB2(@GLuint int shader, @Constant("path.length") @GLsizei int count, - @Const @StringList(value = "count", lengths = "length") CharSequence[] path, - @Constant("APIUtils.getLengths(path), 0") @Const IntBuffer length); + @Const @PointerArray(value = "count", lengths = "length") CharSequence[] path, + @Constant("APIUtil.getLengths(path), 0") @Const IntBuffer length); boolean glIsNamedStringARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name); diff --git a/src/templates/org/lwjgl/opengl/ARB_sync.java b/src/templates/org/lwjgl/opengl/ARB_sync.java index eb788797..bc3278ad 100644 --- a/src/templates/org/lwjgl/opengl/ARB_sync.java +++ b/src/templates/org/lwjgl/opengl/ARB_sync.java @@ -32,6 +32,9 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.PointerWrapper; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.IntBuffer; import java.nio.LongBuffer; @@ -70,35 +73,44 @@ public interface ARB_sync { int GL_CONDITION_SATISFIED = 0x911C; int GL_WAIT_FAILED = 0x911D; - @GLpointer("GLsync") + @Reuse("GL32") + @PointerWrapper("GLsync") GLSync glFenceSync(@GLenum int condition, @GLbitfield int flags); - boolean glIsSync(@GLpointer("GLsync") GLSync sync); + @Reuse("GL32") + boolean glIsSync(@PointerWrapper("GLsync") GLSync sync); - void glDeleteSync(@GLpointer("GLsync") GLSync sync); + @Reuse("GL32") + void glDeleteSync(@PointerWrapper("GLsync") GLSync sync); + @Reuse("GL32") @GLenum - int glClientWaitSync(@GLpointer("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout); + int glClientWaitSync(@PointerWrapper("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout); - void glWaitSync(@GLpointer("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout); + @Reuse("GL32") + void glWaitSync(@PointerWrapper("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout); + @Reuse("GL32") @StripPostfix(value = "params", postfix = "64") void glGetInteger64v(@GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer params); + @Reuse("GL32") @Alternate("glGetInteger64v") @GLreturn("params") @StripPostfix(value = "params", postfix = "64") void glGetInteger64v2(@GLenum int pname, @OutParameter @GLint64 LongBuffer params); + @Reuse("GL32") @StripPostfix("values") - void glGetSynciv(@GLpointer("GLsync") GLSync sync, @GLenum int pname, @AutoSize("values") @GLsizei int bufSize, + void glGetSynciv(@PointerWrapper("GLsync") GLSync sync, @GLenum int pname, @AutoSize("values") @GLsizei int bufSize, @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, @OutParameter IntBuffer values); + @Reuse("GL32") @Alternate("glGetSynciv") @GLreturn("values") @StripPostfix("values") - void glGetSynciv2(@GLpointer("GLsync") GLSync sync, @GLenum int pname, @Constant("1") @GLsizei int bufSize, + void glGetSynciv2(@PointerWrapper("GLsync") GLSync sync, @GLenum int pname, @Constant("1") @GLsizei int bufSize, @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, @OutParameter IntBuffer values); } \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_tessellation_shader.java b/src/templates/org/lwjgl/opengl/ARB_tessellation_shader.java index c599c2ba..4177afcd 100644 --- a/src/templates/org/lwjgl/opengl/ARB_tessellation_shader.java +++ b/src/templates/org/lwjgl/opengl/ARB_tessellation_shader.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; import java.nio.FloatBuffer; @@ -114,8 +115,10 @@ public interface ARB_tessellation_shader { int GL_TESS_EVALUATION_SHADER = 0x8E87; int GL_TESS_CONTROL_SHADER = 0x8E88; + @Reuse("GL40") void glPatchParameteri(@GLenum int pname, int value); + @Reuse("GL40") @StripPostfix("values") void glPatchParameterfv(@GLenum int pname, @Check("4") @Const FloatBuffer values); diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_buffer_object.java b/src/templates/org/lwjgl/opengl/ARB_texture_buffer_object.java index 39499120..3e863c67 100644 --- a/src/templates/org/lwjgl/opengl/ARB_texture_buffer_object.java +++ b/src/templates/org/lwjgl/opengl/ARB_texture_buffer_object.java @@ -31,8 +31,8 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLenum; -import org.lwjgl.util.generator.GLuint; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLuint; public interface ARB_texture_buffer_object { diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_compression.java b/src/templates/org/lwjgl/opengl/ARB_texture_compression.java index 542d4fe4..2a555f5d 100644 --- a/src/templates/org/lwjgl/opengl/ARB_texture_compression.java +++ b/src/templates/org/lwjgl/opengl/ARB_texture_compression.java @@ -32,6 +32,9 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLvoid; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_multisample.java b/src/templates/org/lwjgl/opengl/ARB_texture_multisample.java index fe586bf8..348961d6 100644 --- a/src/templates/org/lwjgl/opengl/ARB_texture_multisample.java +++ b/src/templates/org/lwjgl/opengl/ARB_texture_multisample.java @@ -32,6 +32,10 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLbitfield; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.FloatBuffer; @@ -95,17 +99,21 @@ public interface ARB_texture_multisample { int GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910C; int GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910D; + @Reuse("GL32") void glTexImage2DMultisample(@GLenum int target, @GLsizei int samples, int internalformat, @GLsizei int width, @GLsizei int height, boolean fixedsamplelocations); + @Reuse("GL32") void glTexImage3DMultisample(@GLenum int target, @GLsizei int samples, int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, boolean fixedsamplelocations); + @Reuse("GL32") @StripPostfix("val") void glGetMultisamplefv(@GLenum int pname, @GLuint int index, @OutParameter @Check("2") FloatBuffer val); + @Reuse("GL32") void glSampleMaski(@GLuint int index, @GLbitfield int mask); } \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_timer_query.java b/src/templates/org/lwjgl/opengl/ARB_timer_query.java index 52ded87d..0f8e79e0 100644 --- a/src/templates/org/lwjgl/opengl/ARB_timer_query.java +++ b/src/templates/org/lwjgl/opengl/ARB_timer_query.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.LongBuffer; @@ -51,19 +53,24 @@ public interface ARB_timer_query { */ int GL_TIMESTAMP = 0x8E28; + @Reuse("GL33") void glQueryCounter(@GLuint int id, @GLenum int target); + @Reuse("GL33") @StripPostfix("params") void glGetQueryObjecti64v(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer params); + @Reuse("GL33") @Alternate("glGetQueryObjecti64v") @GLreturn("params") @StripPostfix("params") void glGetQueryObjecti64v2(@GLuint int id, @GLenum int pname, @OutParameter @GLint64 LongBuffer params); + @Reuse("GL33") @StripPostfix("params") void glGetQueryObjectui64v(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLuint64 LongBuffer params); + @Reuse("GL33") @Alternate("glGetQueryObjectui64v") @GLreturn("params") @StripPostfix("params") diff --git a/src/templates/org/lwjgl/opengl/ARB_transform_feedback2.java b/src/templates/org/lwjgl/opengl/ARB_transform_feedback2.java index 49afd6aa..26392970 100644 --- a/src/templates/org/lwjgl/opengl/ARB_transform_feedback2.java +++ b/src/templates/org/lwjgl/opengl/ARB_transform_feedback2.java @@ -32,6 +32,11 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLreturn; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.IntBuffer; @@ -48,25 +53,34 @@ public interface ARB_transform_feedback2 { int GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE = 0x8E24; int GL_TRANSFORM_FEEDBACK_BINDING = 0x8E25; + @Reuse("GL40") void glBindTransformFeedback(@GLenum int target, @GLuint int id); + @Reuse("GL40") void glDeleteTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @Const @GLuint IntBuffer ids); + @Reuse("GL40") @Alternate("glDeleteTransformFeedbacks") - void glDeleteTransformFeedbacks(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, id), 0", keepParam = true) int id); + void glDeleteTransformFeedbacks(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, id), 0", keepParam = true) int id); + @Reuse("GL40") void glGenTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids); + @Reuse("GL40") @Alternate("glGenTransformFeedbacks") @GLreturn("ids") void glGenTransformFeedbacks2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer ids); + @Reuse("GL40") boolean glIsTransformFeedback(@GLuint int id); + @Reuse("GL40") void glPauseTransformFeedback(); + @Reuse("GL40") void glResumeTransformFeedback(); + @Reuse("GL40") void glDrawTransformFeedback(@GLenum int mode, @GLuint int id); } \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_transform_feedback3.java b/src/templates/org/lwjgl/opengl/ARB_transform_feedback3.java index da2e9cb4..fadc002f 100644 --- a/src/templates/org/lwjgl/opengl/ARB_transform_feedback3.java +++ b/src/templates/org/lwjgl/opengl/ARB_transform_feedback3.java @@ -32,6 +32,10 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +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; @@ -45,15 +49,20 @@ public interface ARB_transform_feedback3 { int GL_MAX_TRANSFORM_FEEDBACK_BUFFERS = 0x8E70; int GL_MAX_VERTEX_STREAMS = 0x8E71; + @Reuse("GL40") void glDrawTransformFeedbackStream(@GLenum int mode, @GLuint int id, @GLuint int stream); + @Reuse("GL40") void glBeginQueryIndexed(@GLenum int target, @GLuint int index, @GLuint int id); + @Reuse("GL40") void glEndQueryIndexed(@GLenum int target, @GLuint int index); + @Reuse("GL40") @StripPostfix("params") void glGetQueryIndexediv(@GLenum int target, @GLuint int index, @GLenum int pname, @OutParameter @Check("1") IntBuffer params); + @Reuse("GL40") @Alternate("glGetQueryIndexediv") @GLreturn("params") @StripPostfix("params") diff --git a/src/templates/org/lwjgl/opengl/ARB_uniform_buffer_object.java b/src/templates/org/lwjgl/opengl/ARB_uniform_buffer_object.java index 9ee11c9c..1543b14e 100644 --- a/src/templates/org/lwjgl/opengl/ARB_uniform_buffer_object.java +++ b/src/templates/org/lwjgl/opengl/ARB_uniform_buffer_object.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.ByteBuffer; import java.nio.IntBuffer; @@ -98,21 +100,25 @@ public interface ARB_uniform_buffer_object { /** Returned by GetActiveUniformsivARB and GetUniformBlockIndexARB */ int GL_INVALID_INDEX = 0xFFFFFFFF; + @Reuse("GL31") void glGetUniformIndices(@GLuint int program, @AutoSize("uniformIndices") @GLsizei int uniformCount, - @Const @NullTerminated("uniformIndices.remaining()") @GLchar @StringList("uniformCount") ByteBuffer uniformNames, + @Const @NullTerminated("uniformIndices.remaining()") @GLchar @PointerArray("uniformCount") ByteBuffer uniformNames, @OutParameter @GLuint IntBuffer uniformIndices); + @Reuse("GL31") @Alternate(value = "glGetUniformIndices") void glGetUniformIndices(@GLuint int program, @Constant("uniformNames.length") @GLsizei int uniformCount, - @Const @NullTerminated @StringList("uniformCount") CharSequence[] uniformNames, + @Const @NullTerminated @PointerArray("uniformCount") CharSequence[] uniformNames, @OutParameter @Check("uniformNames.length") @GLuint IntBuffer uniformIndices); + @Reuse("GL31") @StripPostfix("params") void glGetActiveUniformsiv(@GLuint int program, @AutoSize("uniformIndices") @GLsizei int uniformCount, @Const @GLuint IntBuffer uniformIndices, @GLenum int pname, @OutParameter @Check("uniformIndices.remaining()") @GLint IntBuffer params); + @Reuse("GL31") @Alternate("glGetActiveUniformsiv") @GLreturn("params") @StripPostfix("params") @@ -121,55 +127,68 @@ public interface ARB_uniform_buffer_object { @GLenum int pname, @OutParameter @GLint IntBuffer params); + @Reuse("GL31") void glGetActiveUniformName(@GLuint int program, @GLuint int uniformIndex, @AutoSize("uniformName") @GLsizei int bufSize, @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, @OutParameter @GLchar ByteBuffer uniformName); + @Reuse("GL31") @Alternate("glGetActiveUniformName") @GLreturn(value = "uniformName", maxLength = "bufSize") void glGetActiveUniformName2(@GLuint int program, @GLuint int uniformIndex, @GLsizei int bufSize, @OutParameter @GLsizei @Constant("uniformName_length, 0") IntBuffer length, @OutParameter @GLchar ByteBuffer uniformName); + @Reuse("GL31") @GLuint int glGetUniformBlockIndex(@GLuint int program, @Const @NullTerminated @GLchar ByteBuffer uniformBlockName); + @Reuse("GL31") @Alternate("glGetUniformBlockIndex") @GLuint int glGetUniformBlockIndex(@GLuint int program, @NullTerminated CharSequence uniformBlockName); + @Reuse("GL31") @StripPostfix("params") void glGetActiveUniformBlockiv(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname, @OutParameter @Check(value = "16") @GLint IntBuffer params); + @Reuse("GL31") @Alternate("glGetActiveUniformBlockiv") @GLreturn("params") @StripPostfix("params") void glGetActiveUniformBlockiv2(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname, @OutParameter @GLint IntBuffer params); + @Reuse("GL31") void glGetActiveUniformBlockName(@GLuint int program, @GLuint int uniformBlockIndex, @AutoSize("uniformBlockName") @GLsizei int bufSize, @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, @OutParameter @GLchar ByteBuffer uniformBlockName); + @Reuse("GL31") @Alternate("glGetActiveUniformBlockName") @GLreturn(value = "uniformBlockName", maxLength = "bufSize") void glGetActiveUniformBlockName2(@GLuint int program, @GLuint int uniformBlockIndex, @GLsizei int bufSize, @OutParameter @GLsizei @Constant("uniformBlockName_length, 0") IntBuffer length, @OutParameter @GLchar ByteBuffer uniformBlockName); + @Reuse("GL30") void glBindBufferRange(@GLenum int target, @GLuint int index, @GLuint int buffer, @GLintptr long offset, @GLsizeiptr long size); + @Reuse("GL30") void glBindBufferBase(@GLenum int target, @GLuint int index, @GLuint int buffer); + @Reuse("GL30") @StripPostfix(value = "data", extension = "") void glGetIntegeri_v(@GLenum int value, @GLuint int index, @OutParameter @Check("4") IntBuffer data); + @Reuse("GL30") @Alternate("glGetIntegeri_v") @GLreturn("data") @StripPostfix("data") void glGetIntegeri_v2(@GLenum int value, @GLuint int index, @OutParameter IntBuffer data); + @Reuse("GL31") void glUniformBlockBinding(@GLuint int program, @GLuint int uniformBlockIndex, @GLuint int uniformBlockBinding); } \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_vertex_array_object.java b/src/templates/org/lwjgl/opengl/ARB_vertex_array_object.java index 4baa92b2..c9a24fab 100644 --- a/src/templates/org/lwjgl/opengl/ARB_vertex_array_object.java +++ b/src/templates/org/lwjgl/opengl/ARB_vertex_array_object.java @@ -32,6 +32,10 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.GLreturn; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.IntBuffer; @@ -43,19 +47,25 @@ public interface ARB_vertex_array_object { */ int GL_VERTEX_ARRAY_BINDING = 0x85B5; + @Reuse("GL30") void glBindVertexArray(@GLuint int array); + @Reuse("GL30") void glDeleteVertexArrays(@AutoSize("arrays") @GLsizei int n, @Const @GLuint IntBuffer arrays); + @Reuse("GL30") @Alternate("glDeleteVertexArrays") - void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, array), 0", keepParam = true) int array); + void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, array), 0", keepParam = true) int array); + @Reuse("GL30") void glGenVertexArrays(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays); + @Reuse("GL30") @Alternate("glGenVertexArrays") @GLreturn("arrays") void glGenVertexArrays2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays); + @Reuse("GL30") boolean glIsVertexArray(@GLuint int array); } \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_vertex_attrib_64bit.java b/src/templates/org/lwjgl/opengl/ARB_vertex_attrib_64bit.java index 930d0ada..2f55f34b 100644 --- a/src/templates/org/lwjgl/opengl/ARB_vertex_attrib_64bit.java +++ b/src/templates/org/lwjgl/opengl/ARB_vertex_attrib_64bit.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.Buffer; import java.nio.DoubleBuffer; @@ -54,31 +55,41 @@ public interface ARB_vertex_attrib_64bit { int GL_DOUBLE_MAT4x2 = 0x8F4D; int GL_DOUBLE_MAT4x3 = 0x8F4E; + @Reuse("GL41") void glVertexAttribL1d(@GLuint int index, double x); + @Reuse("GL41") void glVertexAttribL2d(@GLuint int index, double x, double y); + @Reuse("GL41") void glVertexAttribL3d(@GLuint int index, double x, double y, double z); + @Reuse("GL41") void glVertexAttribL4d(@GLuint int index, double x, double y, double z, double w); + @Reuse("GL41") @StripPostfix("v") void glVertexAttribL1dv(@GLuint int index, @Const @Check("1") DoubleBuffer v); + @Reuse("GL41") @StripPostfix("v") void glVertexAttribL2dv(@GLuint int index, @Const @Check("2") DoubleBuffer v); + @Reuse("GL41") @StripPostfix("v") void glVertexAttribL3dv(@GLuint int index, @Const @Check("3") DoubleBuffer v); + @Reuse("GL41") @StripPostfix("v") void glVertexAttribL4dv(@GLuint int index, @Const @Check("4") DoubleBuffer v); + @Reuse("GL41") 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); + @Reuse("GL41") @StripPostfix("params") void glGetVertexAttribLdv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params); diff --git a/src/templates/org/lwjgl/opengl/ARB_vertex_blend.java b/src/templates/org/lwjgl/opengl/ARB_vertex_blend.java index 22b0d065..234fb512 100644 --- a/src/templates/org/lwjgl/opengl/ARB_vertex_blend.java +++ b/src/templates/org/lwjgl/opengl/ARB_vertex_blend.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/ARB_vertex_program.java b/src/templates/org/lwjgl/opengl/ARB_vertex_program.java index 1f636246..d99ac459 100644 --- a/src/templates/org/lwjgl/opengl/ARB_vertex_program.java +++ b/src/templates/org/lwjgl/opengl/ARB_vertex_program.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; @@ -79,45 +80,59 @@ public interface ARB_vertex_program extends ARB_program { */ int GL_MAX_VERTEX_ATTRIBS_ARB = 0x8869; + @Reuse("ARBVertexShader") @NoErrorCheck void glVertexAttrib1sARB(@GLuint int index, short x); + @Reuse("ARBVertexShader") @NoErrorCheck void glVertexAttrib1fARB(@GLuint int index, float x); + @Reuse("ARBVertexShader") @NoErrorCheck void glVertexAttrib1dARB(@GLuint int index, double x); + @Reuse("ARBVertexShader") @NoErrorCheck void glVertexAttrib2sARB(@GLuint int index, short x, short y); + @Reuse("ARBVertexShader") @NoErrorCheck void glVertexAttrib2fARB(@GLuint int index, float x, float y); + @Reuse("ARBVertexShader") @NoErrorCheck void glVertexAttrib2dARB(@GLuint int index, double x, double y); + @Reuse("ARBVertexShader") @NoErrorCheck void glVertexAttrib3sARB(@GLuint int index, short x, short y, short z); + @Reuse("ARBVertexShader") @NoErrorCheck void glVertexAttrib3fARB(@GLuint int index, float x, float y, float z); + @Reuse("ARBVertexShader") @NoErrorCheck void glVertexAttrib3dARB(@GLuint int index, double x, double y, double z); + @Reuse("ARBVertexShader") @NoErrorCheck void glVertexAttrib4sARB(@GLuint int index, short x, short y, short z, short w); + @Reuse("ARBVertexShader") @NoErrorCheck void glVertexAttrib4fARB(@GLuint int index, float x, float y, float z, float w); + @Reuse("ARBVertexShader") @NoErrorCheck void glVertexAttrib4dARB(@GLuint int index, double x, double y, double z, double w); + @Reuse("ARBVertexShader") @NoErrorCheck void glVertexAttrib4NubARB(@GLuint int index, @GLubyte byte x, @GLubyte byte y, @GLubyte byte z, @GLubyte byte w); + @Reuse("ARBVertexShader") void glVertexAttribPointerARB(@GLuint int index, int size, @AutoType("buffer") @GLenum int type, boolean normalized, @GLsizei int stride, @CachedReference(index = "index", name = "glVertexAttribPointer_buffer") @BufferObject(BufferKind.ArrayVBO) @@ -132,19 +147,25 @@ public interface ARB_vertex_program extends ARB_program { @GLfloat @GLdouble Buffer buffer); + @Reuse("ARBVertexShader") void glEnableVertexAttribArrayARB(@GLuint int index); + @Reuse("ARBVertexShader") void glDisableVertexAttribArrayARB(@GLuint int index); + @Reuse("ARBVertexShader") @StripPostfix("params") void glGetVertexAttribfvARB(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); + @Reuse("ARBVertexShader") @StripPostfix("params") void glGetVertexAttribdvARB(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params); + @Reuse("ARBVertexShader") @StripPostfix("params") void glGetVertexAttribivARB(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + @Reuse("ARBVertexShader") @StripPostfix("result") void glGetVertexAttribPointervARB(@GLuint int index, @GLenum int pname, @Result @GLvoid ByteBuffer result); } diff --git a/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java b/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java index d5221e80..2b3bdb80 100644 --- a/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java +++ b/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; @@ -168,7 +170,7 @@ public interface ARB_vertex_shader { @Alternate(value = "glGetActiveAttribARB", javaAlt = true) @GLreturn(value = "name", maxLength = "maxLength") void glGetActiveAttribARB(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength, - @OutParameter @GLsizei @Constant("name_length, 0, APIUtils.getBufferInt(), 0, APIUtils.getBufferInt(), 1") IntBuffer length, + @OutParameter @GLsizei @Constant("name_length, 0, APIUtil.getBufferInt(), 0, APIUtil.getBufferInt(), 1") IntBuffer length, @OutParameter @GLcharARB ByteBuffer name); /** Overloads glGetActiveAttribARB. This version returns only the attrib size. */ @@ -178,7 +180,7 @@ public interface ARB_vertex_shader { @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, @OutParameter IntBuffer size, @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore - @OutParameter @GLcharARB @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name); + @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name); /** Overloads glGetActiveAttribARB. This version returns only the attrib type. */ @Alternate(value = "glGetActiveAttribARB", javaAlt = true) @@ -187,7 +189,7 @@ public interface ARB_vertex_shader { @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore @OutParameter @GLenum IntBuffer type, - @OutParameter @GLcharARB @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name); + @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name); int glGetAttribLocationARB(@GLhandleARB int programObj, @NullTerminated @Const @GLcharARB ByteBuffer name); diff --git a/src/templates/org/lwjgl/opengl/ARB_vertex_type_2_10_10_10_rev.java b/src/templates/org/lwjgl/opengl/ARB_vertex_type_2_10_10_10_rev.java index 9912e8d0..15fe8bc7 100644 --- a/src/templates/org/lwjgl/opengl/ARB_vertex_type_2_10_10_10_rev.java +++ b/src/templates/org/lwjgl/opengl/ARB_vertex_type_2_10_10_10_rev.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.IntBuffer; @@ -47,135 +49,173 @@ public interface ARB_vertex_type_2_10_10_10_rev { int GL_UNSIGNED_INT_2_10_10_10_REV = GL12.GL_UNSIGNED_INT_2_10_10_10_REV; int GL_INT_2_10_10_10_REV = 0x8D9F; + @Reuse("GL33") @NoErrorCheck void glVertexP2ui(@GLenum int type, @GLuint int value); + @Reuse("GL33") @NoErrorCheck void glVertexP3ui(@GLenum int type, @GLuint int value); + @Reuse("GL33") @NoErrorCheck void glVertexP4ui(@GLenum int type, @GLuint int value); + @Reuse("GL33") @NoErrorCheck @StripPostfix("value") void glVertexP2uiv(@GLenum int type, @Check("2") @Const @GLuint IntBuffer value); + @Reuse("GL33") @NoErrorCheck @StripPostfix("value") void glVertexP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer value); + @Reuse("GL33") @NoErrorCheck @StripPostfix("value") void glVertexP4uiv(@GLenum int type, @Check("4") @Const @GLuint IntBuffer value); + @Reuse("GL33") @NoErrorCheck void glTexCoordP1ui(@GLenum int type, @GLuint int coords); + @Reuse("GL33") @NoErrorCheck void glTexCoordP2ui(@GLenum int type, @GLuint int coords); + @Reuse("GL33") @NoErrorCheck void glTexCoordP3ui(@GLenum int type, @GLuint int coords); + @Reuse("GL33") @NoErrorCheck void glTexCoordP4ui(@GLenum int type, @GLuint int coords); + @Reuse("GL33") @NoErrorCheck @StripPostfix("coords") void glTexCoordP1uiv(@GLenum int type, @Check("1") @Const @GLuint IntBuffer coords); + @Reuse("GL33") @NoErrorCheck @StripPostfix("coords") void glTexCoordP2uiv(@GLenum int type, @Check("2") @Const @GLuint IntBuffer coords); + @Reuse("GL33") @NoErrorCheck @StripPostfix("coords") void glTexCoordP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer coords); + @Reuse("GL33") @NoErrorCheck @StripPostfix("coords") void glTexCoordP4uiv(@GLenum int type, @Check("4") @Const @GLuint IntBuffer coords); + @Reuse("GL33") @NoErrorCheck void glMultiTexCoordP1ui(@GLenum int texture, @GLenum int type, @GLuint int coords); + @Reuse("GL33") @NoErrorCheck void glMultiTexCoordP2ui(@GLenum int texture, @GLenum int type, @GLuint int coords); + @Reuse("GL33") @NoErrorCheck void glMultiTexCoordP3ui(@GLenum int texture, @GLenum int type, @GLuint int coords); + @Reuse("GL33") @NoErrorCheck void glMultiTexCoordP4ui(@GLenum int texture, @GLenum int type, @GLuint int coords); + @Reuse("GL33") @NoErrorCheck @StripPostfix("coords") void glMultiTexCoordP1uiv(@GLenum int texture, @GLenum int type, @Check("1") @Const @GLuint IntBuffer coords); + @Reuse("GL33") @NoErrorCheck @StripPostfix("coords") void glMultiTexCoordP2uiv(@GLenum int texture, @GLenum int type, @Check("2") @Const @GLuint IntBuffer coords); + @Reuse("GL33") @NoErrorCheck @StripPostfix("coords") void glMultiTexCoordP3uiv(@GLenum int texture, @GLenum int type, @Check("3") @Const @GLuint IntBuffer coords); + @Reuse("GL33") @NoErrorCheck @StripPostfix("coords") void glMultiTexCoordP4uiv(@GLenum int texture, @GLenum int type, @Check("4") @Const @GLuint IntBuffer coords); + @Reuse("GL33") @NoErrorCheck void glNormalP3ui(@GLenum int type, @GLuint int coords); + @Reuse("GL33") @NoErrorCheck @StripPostfix("coords") void glNormalP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer coords); + @Reuse("GL33") @NoErrorCheck void glColorP3ui(@GLenum int type, @GLuint int color); + @Reuse("GL33") @NoErrorCheck void glColorP4ui(@GLenum int type, @GLuint int color); + @Reuse("GL33") @NoErrorCheck @StripPostfix("color") void glColorP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer color); + @Reuse("GL33") @NoErrorCheck @StripPostfix("color") void glColorP4uiv(@GLenum int type, @Check("4") @Const @GLuint IntBuffer color); + @Reuse("GL33") @NoErrorCheck void glSecondaryColorP3ui(@GLenum int type, @GLuint int color); + @Reuse("GL33") @NoErrorCheck @StripPostfix("color") void glSecondaryColorP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer color); + @Reuse("GL33") @NoErrorCheck void glVertexAttribP1ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value); + @Reuse("GL33") @NoErrorCheck void glVertexAttribP2ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value); + @Reuse("GL33") @NoErrorCheck void glVertexAttribP3ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value); + @Reuse("GL33") @NoErrorCheck void glVertexAttribP4ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value); + @Reuse("GL33") @NoErrorCheck @StripPostfix("value") void glVertexAttribP1uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("1") @Const @GLuint IntBuffer value); + @Reuse("GL33") @NoErrorCheck @StripPostfix("value") void glVertexAttribP2uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("2") @Const @GLuint IntBuffer value); + @Reuse("GL33") @NoErrorCheck @StripPostfix("value") void glVertexAttribP3uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("3") @Const @GLuint IntBuffer value); + @Reuse("GL33") @NoErrorCheck @StripPostfix("value") void glVertexAttribP4uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("4") @Const @GLuint IntBuffer value); diff --git a/src/templates/org/lwjgl/opengl/ARB_viewport_array.java b/src/templates/org/lwjgl/opengl/ARB_viewport_array.java index 5800f6b0..fa365c7b 100644 --- a/src/templates/org/lwjgl/opengl/ARB_viewport_array.java +++ b/src/templates/org/lwjgl/opengl/ARB_viewport_array.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.DoubleBuffer; import java.nio.FloatBuffer; @@ -71,55 +73,74 @@ public interface ARB_viewport_array { GL_PROVOKING_VERTEX = 0x8E4F, GL_UNDEFINED_VERTEX = 0x8260; + @Reuse("GL41") @StripPostfix("v") void glViewportArrayv(@GLuint int first, @AutoSize(value = "v", expression = " >> 2") @GLsizei int count, @Const FloatBuffer v); + @Reuse("GL41") void glViewportIndexedf(@GLuint int index, float x, float y, float w, float h); + @Reuse("GL41") @StripPostfix("v") void glViewportIndexedfv(@GLuint int index, @Check("4") @Const FloatBuffer v); + @Reuse("GL41") @StripPostfix("v") void glScissorArrayv(@GLuint int first, @AutoSize(value = "v", expression = " >> 2") @GLsizei int count, @Const IntBuffer v); + @Reuse("GL41") void glScissorIndexed(@GLuint int index, int left, int bottom, @GLsizei int width, @GLsizei int height); + @Reuse("GL41") @StripPostfix("v") void glScissorIndexedv(@GLuint int index, @Check("4") @Const IntBuffer v); + @Reuse("GL41") @StripPostfix("v") void glDepthRangeArrayv(@GLuint int first, @AutoSize(value = "v", expression = " >> 1") @GLsizei int count, @Const @GLclampd DoubleBuffer v); + @Reuse("GL41") void glDepthRangeIndexed(@GLuint int index, @GLclampd double n, @GLclampd double f); + @Reuse("GL41") @StripPostfix("data") void glGetFloati_v(@GLenum int target, @GLuint int index, @Check @OutParameter FloatBuffer data); + @Reuse("GL41") @Alternate("glGetFloati_v") @GLreturn("data") @StripPostfix("data") void glGetFloati_v2(@GLenum int target, @GLuint int index, @OutParameter FloatBuffer data); + @Reuse("GL41") @StripPostfix("data") void glGetDoublei_v(@GLenum int target, @GLuint int index, @Check @OutParameter DoubleBuffer data); + @Reuse("GL41") @Alternate("glGetDoublei_v") @GLreturn("data") @StripPostfix("data") void glGetDoublei_v2(@GLenum int target, @GLuint int index, @OutParameter DoubleBuffer data); + // TODO: It's glGetIntegerIndexedvEXT in EXT_draw_buffers2, spec typo? + //@Reuse(extension = "EXT_draw_buffers2", className = "EXTDrawBuffers2") @StripPostfix(value = "v", extension = "EXT") void glGetIntegerIndexedivEXT(@GLenum int target, @GLuint int index, @Check @OutParameter IntBuffer v); + // TODO: It's glGetIntegerIndexedvEXT in EXT_draw_buffers2, spec typo? + //@Reuse(extension = "EXT_draw_buffers2", className = "EXTDrawBuffers2") @Alternate("glGetIntegerIndexedivEXT") @GLreturn("v") @StripPostfix(value = "v", extension = "EXT") void glGetIntegerIndexedivEXT2(@GLenum int target, @GLuint int index, @OutParameter IntBuffer v); + @Reuse("EXTDrawBuffers2") void glEnableIndexedEXT(@GLenum int target, @GLuint int index); + @Reuse("EXTDrawBuffers2") void glDisableIndexedEXT(@GLenum int target, @GLuint int index); + @Reuse("EXTDrawBuffers2") boolean glIsEnabledIndexedEXT(@GLenum int target, @GLuint int index); } \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ATI_draw_buffers.java b/src/templates/org/lwjgl/opengl/ATI_draw_buffers.java index 300f99ae..77bb68e5 100644 --- a/src/templates/org/lwjgl/opengl/ATI_draw_buffers.java +++ b/src/templates/org/lwjgl/opengl/ATI_draw_buffers.java @@ -32,6 +32,9 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLsizei; import java.nio.*; @@ -62,5 +65,5 @@ public interface ATI_draw_buffers { void glDrawBuffersATI(@AutoSize("buffers") @GLsizei int size, @Const @GLenum IntBuffer buffers); @Alternate("glDrawBuffersATI") - void glDrawBuffersATI(@Constant("1") @GLsizei int size, @Constant(value = "APIUtils.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer); + void glDrawBuffersATI(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer); } diff --git a/src/templates/org/lwjgl/opengl/ATI_element_array.java b/src/templates/org/lwjgl/opengl/ATI_element_array.java index b56207e3..9bd04000 100644 --- a/src/templates/org/lwjgl/opengl/ATI_element_array.java +++ b/src/templates/org/lwjgl/opengl/ATI_element_array.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/ATI_envmap_bumpmap.java b/src/templates/org/lwjgl/opengl/ATI_envmap_bumpmap.java index 4e3a3815..40eddb60 100644 --- a/src/templates/org/lwjgl/opengl/ATI_envmap_bumpmap.java +++ b/src/templates/org/lwjgl/opengl/ATI_envmap_bumpmap.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/ATI_fragment_shader.java b/src/templates/org/lwjgl/opengl/ATI_fragment_shader.java index 14d937e5..a0b2bed2 100644 --- a/src/templates/org/lwjgl/opengl/ATI_fragment_shader.java +++ b/src/templates/org/lwjgl/opengl/ATI_fragment_shader.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/ATI_map_object_buffer.java b/src/templates/org/lwjgl/opengl/ATI_map_object_buffer.java index c762c9d6..4e66dd4d 100644 --- a/src/templates/org/lwjgl/opengl/ATI_map_object_buffer.java +++ b/src/templates/org/lwjgl/opengl/ATI_map_object_buffer.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLuint; +import org.lwjgl.util.generator.opengl.GLvoid; import java.nio.*; @@ -62,7 +64,7 @@ public interface ATI_map_object_buffer { */ @CachedResult @GLvoid - @AutoResultSize("GLChecks.getBufferObjectSizeATI(caps, buffer)") + @AutoSize("GLChecks.getBufferObjectSizeATI(caps, buffer)") ByteBuffer glMapObjectBufferATI(@GLuint int buffer); void glUnmapObjectBufferATI(@GLuint int buffer); diff --git a/src/templates/org/lwjgl/opengl/ATI_pn_triangles.java b/src/templates/org/lwjgl/opengl/ATI_pn_triangles.java index 8b2cf9ff..556b6e10 100644 --- a/src/templates/org/lwjgl/opengl/ATI_pn_triangles.java +++ b/src/templates/org/lwjgl/opengl/ATI_pn_triangles.java @@ -31,7 +31,7 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; public interface ATI_pn_triangles { int GL_PN_TRIANGLES_ATI = 0x87F0; diff --git a/src/templates/org/lwjgl/opengl/ATI_separate_stencil.java b/src/templates/org/lwjgl/opengl/ATI_separate_stencil.java index ac5e9136..0fe735fe 100644 --- a/src/templates/org/lwjgl/opengl/ATI_separate_stencil.java +++ b/src/templates/org/lwjgl/opengl/ATI_separate_stencil.java @@ -31,7 +31,8 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLuint; public interface ATI_separate_stencil { int GL_STENCIL_BACK_FUNC_ATI = 0x8800; diff --git a/src/templates/org/lwjgl/opengl/ATI_vertex_array_object.java b/src/templates/org/lwjgl/opengl/ATI_vertex_array_object.java index d3510071..bde828c6 100644 --- a/src/templates/org/lwjgl/opengl/ATI_vertex_array_object.java +++ b/src/templates/org/lwjgl/opengl/ATI_vertex_array_object.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/ATI_vertex_attrib_array_object.java b/src/templates/org/lwjgl/opengl/ATI_vertex_attrib_array_object.java index a32ecdfc..313f6d7d 100644 --- a/src/templates/org/lwjgl/opengl/ATI_vertex_attrib_array_object.java +++ b/src/templates/org/lwjgl/opengl/ATI_vertex_attrib_array_object.java @@ -32,6 +32,9 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/ATI_vertex_streams.java b/src/templates/org/lwjgl/opengl/ATI_vertex_streams.java index cb585d17..1820f982 100644 --- a/src/templates/org/lwjgl/opengl/ATI_vertex_streams.java +++ b/src/templates/org/lwjgl/opengl/ATI_vertex_streams.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; public interface ATI_vertex_streams { int GL_MAX_VERTEX_STREAMS_ATI = 0x876B; diff --git a/src/templates/org/lwjgl/opengl/EXT_bindable_uniform.java b/src/templates/org/lwjgl/opengl/EXT_bindable_uniform.java index 789e290e..9cfdede5 100644 --- a/src/templates/org/lwjgl/opengl/EXT_bindable_uniform.java +++ b/src/templates/org/lwjgl/opengl/EXT_bindable_uniform.java @@ -31,8 +31,8 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLintptr; -import org.lwjgl.util.generator.GLuint; +import org.lwjgl.util.generator.opengl.GLintptr; +import org.lwjgl.util.generator.opengl.GLuint; public interface EXT_bindable_uniform { diff --git a/src/templates/org/lwjgl/opengl/EXT_blend_color.java b/src/templates/org/lwjgl/opengl/EXT_blend_color.java index 926245ce..9d826cd8 100644 --- a/src/templates/org/lwjgl/opengl/EXT_blend_color.java +++ b/src/templates/org/lwjgl/opengl/EXT_blend_color.java @@ -31,7 +31,7 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLclampf; public interface EXT_blend_color { diff --git a/src/templates/org/lwjgl/opengl/EXT_blend_equation_separate.java b/src/templates/org/lwjgl/opengl/EXT_blend_equation_separate.java index bc5a19b3..b3032c31 100644 --- a/src/templates/org/lwjgl/opengl/EXT_blend_equation_separate.java +++ b/src/templates/org/lwjgl/opengl/EXT_blend_equation_separate.java @@ -31,7 +31,7 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; public interface EXT_blend_equation_separate { diff --git a/src/templates/org/lwjgl/opengl/EXT_blend_func_separate.java b/src/templates/org/lwjgl/opengl/EXT_blend_func_separate.java index 266c955e..f745e779 100644 --- a/src/templates/org/lwjgl/opengl/EXT_blend_func_separate.java +++ b/src/templates/org/lwjgl/opengl/EXT_blend_func_separate.java @@ -31,7 +31,7 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; public interface EXT_blend_func_separate { int GL_BLEND_DST_RGB_EXT = 0x80C8; diff --git a/src/templates/org/lwjgl/opengl/EXT_blend_minmax.java b/src/templates/org/lwjgl/opengl/EXT_blend_minmax.java index 058adcf8..d70fee4d 100644 --- a/src/templates/org/lwjgl/opengl/EXT_blend_minmax.java +++ b/src/templates/org/lwjgl/opengl/EXT_blend_minmax.java @@ -31,7 +31,7 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; public interface EXT_blend_minmax { diff --git a/src/templates/org/lwjgl/opengl/EXT_compiled_vertex_array.java b/src/templates/org/lwjgl/opengl/EXT_compiled_vertex_array.java index b9b3aebe..94e7faf4 100644 --- a/src/templates/org/lwjgl/opengl/EXT_compiled_vertex_array.java +++ b/src/templates/org/lwjgl/opengl/EXT_compiled_vertex_array.java @@ -31,7 +31,7 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLsizei; public interface EXT_compiled_vertex_array { int GL_ARRAY_ELEMENT_LOCK_FIRST_EXT = 0x81A8; diff --git a/src/templates/org/lwjgl/opengl/EXT_depth_bounds_test.java b/src/templates/org/lwjgl/opengl/EXT_depth_bounds_test.java index c35bc314..5a766d9c 100644 --- a/src/templates/org/lwjgl/opengl/EXT_depth_bounds_test.java +++ b/src/templates/org/lwjgl/opengl/EXT_depth_bounds_test.java @@ -31,7 +31,7 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLclampd; public interface EXT_depth_bounds_test { diff --git a/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java b/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java index f78f2993..98e5ded2 100644 --- a/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java +++ b/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; @@ -598,32 +599,39 @@ public interface EXT_direct_state_access { TODO: Why 1.2.1 and not EXT_draw_buffers2? */ - @Dependent("GL_EXT_draw_buffers2") + @Reuse("EXTDrawBuffers2") + @Dependent("OpenGL13") void glEnableIndexedEXT(@GLenum int cap, @GLuint int index); - @Dependent("GL_EXT_draw_buffers2") + @Reuse("EXTDrawBuffers2") + @Dependent("OpenGL13") void glDisableIndexedEXT(@GLenum int cap, @GLuint int index); - @Dependent("GL_EXT_draw_buffers2") + @Reuse("EXTDrawBuffers2") + @Dependent("OpenGL13") boolean glIsEnabledIndexedEXT(@GLenum int cap, @GLuint int index); - @Dependent("GL_EXT_draw_buffers2") + @Reuse("EXTDrawBuffers2") + @Dependent("OpenGL13") @StripPostfix("params") void glGetIntegerIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") IntBuffer params); + @Reuse("EXTDrawBuffers2") @Alternate("glGetIntegerIndexedvEXT") @GLreturn("params") - @Dependent("GL_EXT_draw_buffers2") + @Dependent("OpenGL13") @StripPostfix("params") void glGetIntegerIndexedvEXT2(@GLenum int pname, @GLuint int index, @OutParameter IntBuffer params); - @Dependent("GL_EXT_draw_buffers2") + @Reuse("EXTDrawBuffers2") + @Dependent("OpenGL13") @StripPostfix("params") - void glGetBooleanIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") @GLboolean ByteBuffer params); + void glGetBooleanIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("4") @GLboolean ByteBuffer params); + @Reuse("EXTDrawBuffers2") @Alternate("glGetBooleanIndexedvEXT") @GLreturn("params") - @Dependent("GL_EXT_draw_buffers2") + @Dependent("OpenGL13") @StripPostfix("params") void glGetBooleanIndexedvEXT2(@GLenum int pname, @GLuint int index, @OutParameter @GLboolean ByteBuffer params); @@ -819,13 +827,13 @@ public interface EXT_direct_state_access { @GLint Buffer img); @Dependent("OpenGL13") - void glGetCompressedTexImage(@GLenum int target, int lod, - @OutParameter - @BufferObject(BufferKind.PackPBO) - @Check - @GLbyte - @GLshort - @GLint Buffer img); + void glGetCompressedMultiTexImage(@GLenum int texunit, @GLenum int target, int level, + @OutParameter + @BufferObject(BufferKind.PackPBO) + @Check + @GLbyte + @GLshort + @GLint Buffer img); /* OpenGL 1.3: New transpose matrix commands add "Matrix" suffix @@ -905,7 +913,7 @@ public interface EXT_direct_state_access { @Dependent("OpenGL15") @CachedResult @GLvoid - @AutoResultSize("GLChecks.getNamedBufferObjectSize(caps, buffer)") + @AutoSize("GLChecks.getNamedBufferObjectSize(caps, buffer)") ByteBuffer glMapNamedBufferEXT(@GLuint int buffer, @GLenum int access); @Dependent("OpenGL15") @@ -923,7 +931,7 @@ public interface EXT_direct_state_access { @Dependent("OpenGL15") @StripPostfix("params") - @AutoResultSize("GLChecks.getNamedBufferObjectSize(caps, buffer)") + @AutoSize("GLChecks.getNamedBufferObjectSize(caps, buffer)") void glGetNamedBufferPointervEXT(@GLuint int buffer, @GLenum int pname, @OutParameter @Result @GLvoid ByteBuffer params); @Dependent("OpenGL15") @@ -1075,7 +1083,7 @@ public interface EXT_direct_state_access { @Alternate("glTextureParameterIivEXT") @Dependent("GL_EXT_texture_integer") @StripPostfix("param") - void glTextureParameterIivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) int param); + void glTextureParameterIivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) int param); @Dependent("GL_EXT_texture_integer") @StripPostfix("params") @@ -1084,7 +1092,7 @@ public interface EXT_direct_state_access { @Alternate("glTextureParameterIuivEXT") @Dependent("GL_EXT_texture_integer") @StripPostfix("param") - void glTextureParameterIuivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) @GLuint int param); + void glTextureParameterIuivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) @GLuint int param); @Dependent("GL_EXT_texture_integer") @StripPostfix("params") @@ -1119,7 +1127,7 @@ public interface EXT_direct_state_access { @Alternate("glMultiTexParameterIivEXT") @Dependent("GL_EXT_texture_integer") @StripPostfix("param") - void glMultiTexParameterIivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) int param); + void glMultiTexParameterIivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) int param); @Dependent("GL_EXT_texture_integer") @StripPostfix("params") @@ -1128,7 +1136,7 @@ public interface EXT_direct_state_access { @Alternate("glMultiTexParameterIuivEXT") @Dependent("GL_EXT_texture_integer") @StripPostfix("param") - void glMultiTexParameterIuivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) int param); + void glMultiTexParameterIuivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) int param); @Dependent("GL_EXT_texture_integer") @StripPostfix("params") @@ -1505,7 +1513,7 @@ public interface EXT_direct_state_access { @Dependent("OpenGL30") @CachedResult(isRange = true) @GLvoid - @AutoResultSize("length") + @AutoSize("length") ByteBuffer glMapNamedBufferRangeEXT(@GLuint int buffer, @GLintptr long offset, @GLsizeiptr long length, @GLbitfield int access); @Dependent("OpenGL30") diff --git a/src/templates/org/lwjgl/opengl/EXT_draw_buffers2.java b/src/templates/org/lwjgl/opengl/EXT_draw_buffers2.java index 8794b916..3b396bb2 100644 --- a/src/templates/org/lwjgl/opengl/EXT_draw_buffers2.java +++ b/src/templates/org/lwjgl/opengl/EXT_draw_buffers2.java @@ -32,6 +32,11 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.GLboolean; +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; import java.nio.ByteBuffer; diff --git a/src/templates/org/lwjgl/opengl/EXT_draw_instanced.java b/src/templates/org/lwjgl/opengl/EXT_draw_instanced.java index 5baa846b..d1144987 100644 --- a/src/templates/org/lwjgl/opengl/EXT_draw_instanced.java +++ b/src/templates/org/lwjgl/opengl/EXT_draw_instanced.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.Buffer; diff --git a/src/templates/org/lwjgl/opengl/EXT_draw_range_elements.java b/src/templates/org/lwjgl/opengl/EXT_draw_range_elements.java index f576009b..a9914273 100644 --- a/src/templates/org/lwjgl/opengl/EXT_draw_range_elements.java +++ b/src/templates/org/lwjgl/opengl/EXT_draw_range_elements.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/EXT_fog_coord.java b/src/templates/org/lwjgl/opengl/EXT_fog_coord.java index 331a3272..0db7d2dc 100644 --- a/src/templates/org/lwjgl/opengl/EXT_fog_coord.java +++ b/src/templates/org/lwjgl/opengl/EXT_fog_coord.java @@ -32,6 +32,10 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLdouble; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLfloat; +import org.lwjgl.util.generator.opengl.GLsizei; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/EXT_framebuffer_blit.java b/src/templates/org/lwjgl/opengl/EXT_framebuffer_blit.java index 203efd83..b13ee0fe 100644 --- a/src/templates/org/lwjgl/opengl/EXT_framebuffer_blit.java +++ b/src/templates/org/lwjgl/opengl/EXT_framebuffer_blit.java @@ -31,7 +31,9 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLbitfield; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLint; public interface EXT_framebuffer_blit { diff --git a/src/templates/org/lwjgl/opengl/EXT_framebuffer_multisample.java b/src/templates/org/lwjgl/opengl/EXT_framebuffer_multisample.java index 62714129..9f75aa5a 100644 --- a/src/templates/org/lwjgl/opengl/EXT_framebuffer_multisample.java +++ b/src/templates/org/lwjgl/opengl/EXT_framebuffer_multisample.java @@ -31,8 +31,8 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLenum; -import org.lwjgl.util.generator.GLsizei; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLsizei; public interface EXT_framebuffer_multisample { diff --git a/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java b/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java index cc9c98c0..a7bd1220 100644 --- a/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java +++ b/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java @@ -32,6 +32,11 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLreturn; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.IntBuffer; @@ -131,7 +136,7 @@ public interface EXT_framebuffer_object { void glDeleteRenderbuffersEXT(@AutoSize("renderbuffers") int n, @Const @GLuint IntBuffer renderbuffers); @Alternate("glDeleteRenderbuffersEXT") - void glDeleteRenderbuffersEXT(@Constant("1") int n, @Constant(value = "APIUtils.getBufferInt().put(0, renderbuffer), 0", keepParam = true) int renderbuffer); + void glDeleteRenderbuffersEXT(@Constant("1") int n, @Constant(value = "APIUtil.getBufferInt().put(0, renderbuffer), 0", keepParam = true) int renderbuffer); void glGenRenderbuffersEXT(@AutoSize("renderbuffers") int n, @OutParameter @GLuint IntBuffer renderbuffers); @@ -156,7 +161,7 @@ public interface EXT_framebuffer_object { void glDeleteFramebuffersEXT(@AutoSize("framebuffers") int n, @Const @GLuint IntBuffer framebuffers); @Alternate("glDeleteFramebuffersEXT") - void glDeleteFramebuffersEXT(@Constant("1") int n, @Constant(value = "APIUtils.getBufferInt().put(0, framebuffer), 0", keepParam = true) int framebuffer); + void glDeleteFramebuffersEXT(@Constant("1") int n, @Constant(value = "APIUtil.getBufferInt().put(0, framebuffer), 0", keepParam = true) int framebuffer); void glGenFramebuffersEXT(@AutoSize("framebuffers") int n, @OutParameter @GLuint IntBuffer framebuffers); diff --git a/src/templates/org/lwjgl/opengl/EXT_geometry_shader4.java b/src/templates/org/lwjgl/opengl/EXT_geometry_shader4.java index 5745ca03..5c9639c5 100644 --- a/src/templates/org/lwjgl/opengl/EXT_geometry_shader4.java +++ b/src/templates/org/lwjgl/opengl/EXT_geometry_shader4.java @@ -31,8 +31,8 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLenum; -import org.lwjgl.util.generator.GLuint; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLuint; public interface EXT_geometry_shader4 { diff --git a/src/templates/org/lwjgl/opengl/EXT_gpu_program_parameters.java b/src/templates/org/lwjgl/opengl/EXT_gpu_program_parameters.java index 3cde1bfb..24ff9b5d 100644 --- a/src/templates/org/lwjgl/opengl/EXT_gpu_program_parameters.java +++ b/src/templates/org/lwjgl/opengl/EXT_gpu_program_parameters.java @@ -32,6 +32,9 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/EXT_gpu_shader4.java b/src/templates/org/lwjgl/opengl/EXT_gpu_shader4.java index 283903fe..c4608ed9 100644 --- a/src/templates/org/lwjgl/opengl/EXT_gpu_shader4.java +++ b/src/templates/org/lwjgl/opengl/EXT_gpu_shader4.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.Buffer; import java.nio.ByteBuffer; diff --git a/src/templates/org/lwjgl/opengl/EXT_multi_draw_arrays.java b/src/templates/org/lwjgl/opengl/EXT_multi_draw_arrays.java index 1437cf88..3f86993a 100644 --- a/src/templates/org/lwjgl/opengl/EXT_multi_draw_arrays.java +++ b/src/templates/org/lwjgl/opengl/EXT_multi_draw_arrays.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLsizei; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/EXT_paletted_texture.java b/src/templates/org/lwjgl/opengl/EXT_paletted_texture.java index 1997a083..b0c88322 100644 --- a/src/templates/org/lwjgl/opengl/EXT_paletted_texture.java +++ b/src/templates/org/lwjgl/opengl/EXT_paletted_texture.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/EXT_point_parameters.java b/src/templates/org/lwjgl/opengl/EXT_point_parameters.java index 61c94383..55809872 100644 --- a/src/templates/org/lwjgl/opengl/EXT_point_parameters.java +++ b/src/templates/org/lwjgl/opengl/EXT_point_parameters.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/EXT_provoking_vertex.java b/src/templates/org/lwjgl/opengl/EXT_provoking_vertex.java index 7d919788..5037f556 100644 --- a/src/templates/org/lwjgl/opengl/EXT_provoking_vertex.java +++ b/src/templates/org/lwjgl/opengl/EXT_provoking_vertex.java @@ -31,7 +31,7 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLenum; +import org.lwjgl.util.generator.opengl.GLenum; public interface EXT_provoking_vertex { diff --git a/src/templates/org/lwjgl/opengl/EXT_secondary_color.java b/src/templates/org/lwjgl/opengl/EXT_secondary_color.java index 10e55e40..63fba719 100644 --- a/src/templates/org/lwjgl/opengl/EXT_secondary_color.java +++ b/src/templates/org/lwjgl/opengl/EXT_secondary_color.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.Buffer; diff --git a/src/templates/org/lwjgl/opengl/EXT_separate_shader_objects.java b/src/templates/org/lwjgl/opengl/EXT_separate_shader_objects.java index 152d4b11..f9a064c9 100644 --- a/src/templates/org/lwjgl/opengl/EXT_separate_shader_objects.java +++ b/src/templates/org/lwjgl/opengl/EXT_separate_shader_objects.java @@ -32,6 +32,10 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.GLchar; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.ByteBuffer; diff --git a/src/templates/org/lwjgl/opengl/EXT_shader_image_load_store.java b/src/templates/org/lwjgl/opengl/EXT_shader_image_load_store.java index 02093bb7..b1bfd3bd 100644 --- a/src/templates/org/lwjgl/opengl/EXT_shader_image_load_store.java +++ b/src/templates/org/lwjgl/opengl/EXT_shader_image_load_store.java @@ -31,9 +31,9 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLbitfield; -import org.lwjgl.util.generator.GLenum; -import org.lwjgl.util.generator.GLuint; +import org.lwjgl.util.generator.opengl.GLbitfield; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLuint; public interface EXT_shader_image_load_store { diff --git a/src/templates/org/lwjgl/opengl/EXT_stencil_clear_tag.java b/src/templates/org/lwjgl/opengl/EXT_stencil_clear_tag.java index 166e985d..26bf12f1 100644 --- a/src/templates/org/lwjgl/opengl/EXT_stencil_clear_tag.java +++ b/src/templates/org/lwjgl/opengl/EXT_stencil_clear_tag.java @@ -31,7 +31,8 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; public interface EXT_stencil_clear_tag { diff --git a/src/templates/org/lwjgl/opengl/EXT_stencil_two_side.java b/src/templates/org/lwjgl/opengl/EXT_stencil_two_side.java index ec04da2f..bb74b737 100644 --- a/src/templates/org/lwjgl/opengl/EXT_stencil_two_side.java +++ b/src/templates/org/lwjgl/opengl/EXT_stencil_two_side.java @@ -31,7 +31,7 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; public interface EXT_stencil_two_side { int GL_STENCIL_TEST_TWO_SIDE_EXT = 0x8910; diff --git a/src/templates/org/lwjgl/opengl/EXT_texture_array.java b/src/templates/org/lwjgl/opengl/EXT_texture_array.java index b9eed411..1ba0ae30 100644 --- a/src/templates/org/lwjgl/opengl/EXT_texture_array.java +++ b/src/templates/org/lwjgl/opengl/EXT_texture_array.java @@ -31,8 +31,9 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLenum; -import org.lwjgl.util.generator.GLuint; +import org.lwjgl.util.generator.Reuse; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLuint; public interface EXT_texture_array { @@ -83,6 +84,7 @@ public interface EXT_texture_array { int GL_SAMPLER_1D_ARRAY_SHADOW_EXT = 0x8DC3; int GL_SAMPLER_2D_ARRAY_SHADOW_EXT = 0x8DC4; + @Reuse("EXTGeometryShader4") void glFramebufferTextureLayerEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer); } \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_texture_buffer_object.java b/src/templates/org/lwjgl/opengl/EXT_texture_buffer_object.java index 1601fc20..597ddf5a 100644 --- a/src/templates/org/lwjgl/opengl/EXT_texture_buffer_object.java +++ b/src/templates/org/lwjgl/opengl/EXT_texture_buffer_object.java @@ -31,8 +31,8 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLenum; -import org.lwjgl.util.generator.GLuint; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLuint; public interface EXT_texture_buffer_object { diff --git a/src/templates/org/lwjgl/opengl/EXT_texture_integer.java b/src/templates/org/lwjgl/opengl/EXT_texture_integer.java index 46bf0037..520b40db 100644 --- a/src/templates/org/lwjgl/opengl/EXT_texture_integer.java +++ b/src/templates/org/lwjgl/opengl/EXT_texture_integer.java @@ -32,6 +32,10 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +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; @@ -114,14 +118,14 @@ public interface EXT_texture_integer { @Alternate("glTexParameterIivEXT") @StripPostfix(value = "param", postfix = "v") - void glTexParameterIivEXT(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) int param); + void glTexParameterIivEXT(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", 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 = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) int param); + void glTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) int param); @StripPostfix("params") void glGetTexParameterIivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); diff --git a/src/templates/org/lwjgl/opengl/EXT_timer_query.java b/src/templates/org/lwjgl/opengl/EXT_timer_query.java index 520c729e..897aeeb5 100644 --- a/src/templates/org/lwjgl/opengl/EXT_timer_query.java +++ b/src/templates/org/lwjgl/opengl/EXT_timer_query.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/EXT_transform_feedback.java b/src/templates/org/lwjgl/opengl/EXT_transform_feedback.java index 66cdc3f2..204adae0 100644 --- a/src/templates/org/lwjgl/opengl/EXT_transform_feedback.java +++ b/src/templates/org/lwjgl/opengl/EXT_transform_feedback.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.ByteBuffer; import java.nio.IntBuffer; @@ -102,12 +104,12 @@ public interface EXT_transform_feedback { void glEndTransformFeedbackEXT(); void glTransformFeedbackVaryingsEXT(@GLuint int program, @GLsizei int count, - @Const @NullTerminated("count") @GLchar @StringList("count") ByteBuffer varyings, + @Const @NullTerminated("count") @GLchar @PointerArray("count") ByteBuffer varyings, @GLenum int bufferMode); @Alternate("glTransformFeedbackVaryingsEXT") void glTransformFeedbackVaryingsEXT(@GLuint int program, @Constant("varyings.length") @GLsizei int count, - @Const @NullTerminated @StringList("count") CharSequence[] varyings, + @Const @NullTerminated @PointerArray("count") CharSequence[] varyings, @GLenum int bufferMode); void glGetTransformFeedbackVaryingEXT(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int bufSize, diff --git a/src/templates/org/lwjgl/opengl/EXT_vertex_attrib_64bit.java b/src/templates/org/lwjgl/opengl/EXT_vertex_attrib_64bit.java index 2794a93e..42755095 100644 --- a/src/templates/org/lwjgl/opengl/EXT_vertex_attrib_64bit.java +++ b/src/templates/org/lwjgl/opengl/EXT_vertex_attrib_64bit.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.Buffer; import java.nio.DoubleBuffer; @@ -81,6 +82,7 @@ public interface EXT_vertex_attrib_64bit { @StripPostfix("params") void glGetVertexAttribLdvEXT(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params); + @Reuse("ARBVertexAttrib64bit") @Dependent("EXT_direct_state_access") void glVertexArrayVertexAttribLOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLuint int index, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset); diff --git a/src/templates/org/lwjgl/opengl/EXT_vertex_shader.java b/src/templates/org/lwjgl/opengl/EXT_vertex_shader.java index 553df9f6..b8a4e531 100644 --- a/src/templates/org/lwjgl/opengl/EXT_vertex_shader.java +++ b/src/templates/org/lwjgl/opengl/EXT_vertex_shader.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/EXT_vertex_weighting.java b/src/templates/org/lwjgl/opengl/EXT_vertex_weighting.java index 3788e78f..321e3712 100644 --- a/src/templates/org/lwjgl/opengl/EXT_vertex_weighting.java +++ b/src/templates/org/lwjgl/opengl/EXT_vertex_weighting.java @@ -32,6 +32,9 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLfloat; +import org.lwjgl.util.generator.opengl.GLsizei; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/GL11.java b/src/templates/org/lwjgl/opengl/GL11.java index de7b60b5..18e7646f 100644 --- a/src/templates/org/lwjgl/opengl/GL11.java +++ b/src/templates/org/lwjgl/opengl/GL11.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; @@ -782,7 +784,7 @@ public interface GL11 { void glDeleteTextures(@AutoSize("textures") @GLsizei int n, @Const @GLuint IntBuffer textures); @Alternate("glDeleteTextures") - void glDeleteTextures(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, texture), 0", keepParam = true) int texture); + void glDeleteTextures(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, texture), 0", keepParam = true) int texture); void glCullFace(@GLenum int mode); diff --git a/src/templates/org/lwjgl/opengl/GL12.java b/src/templates/org/lwjgl/opengl/GL12.java index 564012b0..bfeb6ed9 100644 --- a/src/templates/org/lwjgl/opengl/GL12.java +++ b/src/templates/org/lwjgl/opengl/GL12.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.Buffer; diff --git a/src/templates/org/lwjgl/opengl/GL13.java b/src/templates/org/lwjgl/opengl/GL13.java index 68b9b614..b5ee5164 100644 --- a/src/templates/org/lwjgl/opengl/GL13.java +++ b/src/templates/org/lwjgl/opengl/GL13.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/GL14.java b/src/templates/org/lwjgl/opengl/GL14.java index e93dbc2d..a92e7877 100644 --- a/src/templates/org/lwjgl/opengl/GL14.java +++ b/src/templates/org/lwjgl/opengl/GL14.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/GL15.java b/src/templates/org/lwjgl/opengl/GL15.java index bc9adf01..a45f6b35 100644 --- a/src/templates/org/lwjgl/opengl/GL15.java +++ b/src/templates/org/lwjgl/opengl/GL15.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.Buffer; import java.nio.ByteBuffer; @@ -95,7 +97,7 @@ public interface GL15 { void glDeleteBuffers(@AutoSize("buffers") @GLsizei int n, @Const @GLuint IntBuffer buffers); @Alternate("glDeleteBuffers") - void glDeleteBuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer); + void glDeleteBuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer); void glGenBuffers(@AutoSize("buffers") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers); @@ -156,7 +158,7 @@ public interface GL15 { */ @CachedResult @GLvoid - @AutoResultSize("GLChecks.getBufferObjectSize(caps, target)") + @AutoSize("GLChecks.getBufferObjectSize(caps, target)") ByteBuffer glMapBuffer(@GLenum int target, @GLenum int access); boolean glUnmapBuffer(@GLenum int target); @@ -170,7 +172,7 @@ public interface GL15 { void glGetBufferParameteriv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params); @StripPostfix("pointer") - @AutoResultSize("GLChecks.getBufferObjectSize(caps, target)") + @AutoSize("GLChecks.getBufferObjectSize(caps, target)") void glGetBufferPointerv(@GLenum int target, @GLenum int pname, @OutParameter @Result @GLvoid ByteBuffer pointer); // ----------------------------------------------------------------- @@ -203,7 +205,7 @@ public interface GL15 { void glDeleteQueries(@AutoSize("ids") @GLsizei int n, @GLuint IntBuffer ids); @Alternate("glDeleteQueries") - void glDeleteQueries(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, id), 0", keepParam = true) int id); + void glDeleteQueries(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, id), 0", keepParam = true) int id); boolean glIsQuery(@GLuint int id); diff --git a/src/templates/org/lwjgl/opengl/GL20.java b/src/templates/org/lwjgl/opengl/GL20.java index f94129c9..67c4815d 100644 --- a/src/templates/org/lwjgl/opengl/GL20.java +++ b/src/templates/org/lwjgl/opengl/GL20.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; @@ -105,8 +107,8 @@ public interface GL20 { @Alternate(value = "glShaderSource", nativeAlt = true) void glShaderSource3(@GLuint int shader, @Constant("strings.length") @GLsizei int count, - @Const @StringList(value = "count", lengths = "length") CharSequence[] strings, - @Constant("APIUtils.getLengths(strings), 0") @Const IntBuffer length); + @Const @PointerArray(value = "count", lengths = "length") CharSequence[] strings, + @Constant("APIUtil.getLengths(strings), 0") @Const IntBuffer length); int glCreateShader(@GLuint int type); @@ -255,7 +257,7 @@ public interface GL20 { @Alternate(value = "glGetActiveUniform", javaAlt = true) @GLreturn(value = "name", maxLength = "maxLength") void glGetActiveUniform(@GLuint int program, @GLuint int index, @GLsizei int maxLength, - @OutParameter @GLsizei @Constant("name_length, 0, APIUtils.getBufferInt(), 0, APIUtils.getBufferInt(), 1") IntBuffer length, + @OutParameter @GLsizei @Constant("name_length, 0, APIUtil.getBufferInt(), 0, APIUtil.getBufferInt(), 1") IntBuffer length, @OutParameter @GLchar ByteBuffer name); /** Overloads glGetActiveUniform. This version returns only the uniform size. */ @@ -265,7 +267,7 @@ public interface GL20 { @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, @OutParameter IntBuffer size, @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore - @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name); + @OutParameter @GLchar @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name); /** Overloads glGetActiveUniform. This version returns only the uniform type. */ @Alternate(value = "glGetActiveUniform", javaAlt = true) @@ -274,7 +276,7 @@ public interface GL20 { @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore @OutParameter @GLenum IntBuffer type, - @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name); + @OutParameter @GLchar @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name); @StripPostfix("params") void glGetUniformfv(@GLuint int program, int location, @OutParameter @Check FloatBuffer params); @@ -430,7 +432,7 @@ public interface GL20 { @Alternate(value = "glGetActiveAttrib", javaAlt = true) @GLreturn(value = "name", maxLength = "maxLength") void glGetActiveAttrib(@GLuint int program, @GLuint int index, @GLsizei int maxLength, - @OutParameter @GLsizei @Constant("name_length, 0, APIUtils.getBufferInt(), 0, APIUtils.getBufferInt(), 1") IntBuffer length, + @OutParameter @GLsizei @Constant("name_length, 0, APIUtil.getBufferInt(), 0, APIUtil.getBufferInt(), 1") IntBuffer length, @OutParameter @GLchar ByteBuffer name); /** Overloads glGetActiveAttribARB. This version returns only the attrib size. */ @@ -440,7 +442,7 @@ public interface GL20 { @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, @OutParameter IntBuffer size, @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore - @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name); + @OutParameter @GLchar @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name); /** Overloads glGetActiveAttrib. This version returns only the attrib type. */ @Alternate(value = "glGetActiveAttrib", javaAlt = true) @@ -449,7 +451,7 @@ public interface GL20 { @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore @OutParameter @GLenum IntBuffer type, - @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name); + @OutParameter @GLchar @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name); int glGetAttribLocation(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name); @@ -507,7 +509,7 @@ public interface GL20 { void glDrawBuffers(@AutoSize("buffers") @GLsizei int size, @Const @GLenum IntBuffer buffers); @Alternate("glDrawBuffers") - void glDrawBuffers(@Constant("1") @GLsizei int size, @Constant(value = "APIUtils.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer); + void glDrawBuffers(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer); // ---------------------------------------------------------------- // ----------------------[ ARB_point_sprite ]---------------------- diff --git a/src/templates/org/lwjgl/opengl/GL21.java b/src/templates/org/lwjgl/opengl/GL21.java index 5c845592..4da8e1ae 100644 --- a/src/templates/org/lwjgl/opengl/GL21.java +++ b/src/templates/org/lwjgl/opengl/GL21.java @@ -32,7 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.AutoSize; -import org.lwjgl.util.generator.GLsizei; +import org.lwjgl.util.generator.opengl.GLsizei; import org.lwjgl.util.generator.StripPostfix; import java.nio.FloatBuffer; diff --git a/src/templates/org/lwjgl/opengl/GL30.java b/src/templates/org/lwjgl/opengl/GL30.java index 3f8e7073..dc2d74c2 100644 --- a/src/templates/org/lwjgl/opengl/GL30.java +++ b/src/templates/org/lwjgl/opengl/GL30.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; @@ -294,7 +296,7 @@ public interface GL30 { */ @CachedResult(isRange = true) @GLvoid - @AutoResultSize("length") + @AutoSize("length") ByteBuffer glMapBufferRange(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length, @GLbitfield int access); void glFlushMappedBufferRange(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length); @@ -526,7 +528,7 @@ public interface GL30 { void glDeleteRenderbuffers(@AutoSize("renderbuffers") int n, @Const @GLuint IntBuffer renderbuffers); @Alternate("glDeleteRenderbuffers") - void glDeleteRenderbuffers(@Constant("1") int n, @Constant(value = "APIUtils.getBufferInt().put(0, renderbuffer), 0", keepParam = true) int renderbuffer); + void glDeleteRenderbuffers(@Constant("1") int n, @Constant(value = "APIUtil.getBufferInt().put(0, renderbuffer), 0", keepParam = true) int renderbuffer); void glGenRenderbuffers(@AutoSize("renderbuffers") int n, @OutParameter @GLuint IntBuffer renderbuffers); @@ -551,7 +553,7 @@ public interface GL30 { void glDeleteFramebuffers(@AutoSize("framebuffers") int n, @Const @GLuint IntBuffer framebuffers); @Alternate("glDeleteFramebuffers") - void glDeleteFramebuffers(@Constant("1") int n, @Constant(value = "APIUtils.getBufferInt().put(0, framebuffer), 0", keepParam = true) int framebuffer); + void glDeleteFramebuffers(@Constant("1") int n, @Constant(value = "APIUtil.getBufferInt().put(0, framebuffer), 0", keepParam = true) int framebuffer); void glGenFramebuffers(@AutoSize("framebuffers") int n, @OutParameter @GLuint IntBuffer framebuffers); @@ -710,14 +712,14 @@ public interface GL30 { @Alternate("glTexParameterIiv") @StripPostfix(value = "param", postfix = "v") - void glTexParameterIiv(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) int param); + void glTexParameterIiv(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) int param); @StripPostfix("params") void glTexParameterIuiv(@GLenum int target, @GLenum int pname, @Check("4") @GLuint IntBuffer params); @Alternate("glTexParameterIuiv") @StripPostfix(value = "param", postfix = "v") - void glTexParameterIuiv(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) int param); + void glTexParameterIuiv(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) int param); @StripPostfix("params") void glGetTexParameterIiv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @@ -977,12 +979,12 @@ public interface GL30 { void glEndTransformFeedback(); void glTransformFeedbackVaryings(@GLuint int program, @GLsizei int count, - @Const @NullTerminated("count") @GLchar @StringList("count") ByteBuffer varyings, + @Const @NullTerminated("count") @GLchar @PointerArray("count") ByteBuffer varyings, @GLenum int bufferMode); @Alternate("glTransformFeedbackVaryings") void glTransformFeedbackVaryings(@GLuint int program, @Constant("varyings.length") @GLsizei int count, - @Const @NullTerminated @StringList("count") CharSequence[] varyings, + @Const @NullTerminated @PointerArray("count") CharSequence[] varyings, @GLenum int bufferMode); void glGetTransformFeedbackVarying(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int bufSize, @@ -1014,7 +1016,7 @@ public interface GL30 { void glDeleteVertexArrays(@AutoSize("arrays") @GLsizei int n, @Const @GLuint IntBuffer arrays); @Alternate("glDeleteVertexArrays") - void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, array), 0", keepParam = true) int array); + void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, array), 0", keepParam = true) int array); void glGenVertexArrays(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays); diff --git a/src/templates/org/lwjgl/opengl/GL31.java b/src/templates/org/lwjgl/opengl/GL31.java index 4baaad7b..880b7119 100644 --- a/src/templates/org/lwjgl/opengl/GL31.java +++ b/src/templates/org/lwjgl/opengl/GL31.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.Buffer; import java.nio.ByteBuffer; @@ -232,12 +234,12 @@ public interface GL31 { int GL_INVALID_INDEX = 0xFFFFFFFF; void glGetUniformIndices(@GLuint int program, @AutoSize("uniformIndices") @GLsizei int uniformCount, - @Const @NullTerminated("uniformIndices.remaining()") @GLchar @StringList("uniformCount") ByteBuffer uniformNames, + @Const @NullTerminated("uniformIndices.remaining()") @GLchar @PointerArray("uniformCount") ByteBuffer uniformNames, @OutParameter @GLuint IntBuffer uniformIndices); @Alternate("glGetUniformIndices") void glGetUniformIndices(@GLuint int program, @Constant("uniformNames.length") @GLsizei int uniformCount, - @Const @NullTerminated @StringList("uniformCount") CharSequence[] uniformNames, + @Const @NullTerminated @PointerArray("uniformCount") CharSequence[] uniformNames, @OutParameter @Check("uniformNames.length") @GLuint IntBuffer uniformIndices); @StripPostfix("params") diff --git a/src/templates/org/lwjgl/opengl/GL32.java b/src/templates/org/lwjgl/opengl/GL32.java index d823725e..8a1c80e4 100644 --- a/src/templates/org/lwjgl/opengl/GL32.java +++ b/src/templates/org/lwjgl/opengl/GL32.java @@ -32,6 +32,9 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.PointerWrapper; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.Buffer; import java.nio.FloatBuffer; @@ -259,8 +262,6 @@ public interface GL32 { void glFramebufferTexture(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level); - void glFramebufferTextureLayer(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer); - // -------------------------------------------------------- // ----------------------[ ARB_sync ]---------------------- // -------------------------------------------------------- @@ -296,17 +297,17 @@ public interface GL32 { int GL_CONDITION_SATISFIED = 0x911C; int GL_WAIT_FAILED = 0x911D; - @GLpointer("GLsync") + @PointerWrapper("GLsync") GLSync glFenceSync(@GLenum int condition, @GLbitfield int flags); - boolean glIsSync(@GLpointer("GLsync") GLSync sync); + boolean glIsSync(@PointerWrapper("GLsync") GLSync sync); - void glDeleteSync(@GLpointer("GLsync") GLSync sync); + void glDeleteSync(@PointerWrapper("GLsync") GLSync sync); @GLenum - int glClientWaitSync(@GLpointer("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout); + int glClientWaitSync(@PointerWrapper("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout); - void glWaitSync(@GLpointer("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout); + void glWaitSync(@PointerWrapper("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout); @StripPostfix(value = "data", postfix = "64") void glGetInteger64v(@GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer data); @@ -326,14 +327,14 @@ public interface GL32 { void glGetInteger64i_v2(@GLenum int value, @GLuint int index, @OutParameter @GLint64 LongBuffer data); @StripPostfix("values") - void glGetSynciv(@GLpointer("GLsync") GLSync sync, @GLenum int pname, @AutoSize("values") @GLsizei int bufSize, + void glGetSynciv(@PointerWrapper("GLsync") GLSync sync, @GLenum int pname, @AutoSize("values") @GLsizei int bufSize, @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, @OutParameter IntBuffer values); @Alternate("glGetSynciv") @GLreturn("values") @StripPostfix("values") - void glGetSynciv2(@GLpointer("GLsync") GLSync sync, @GLenum int pname, @Constant("1") @GLsizei int bufSize, + void glGetSynciv2(@PointerWrapper("GLsync") GLSync sync, @GLenum int pname, @Constant("1") @GLsizei int bufSize, @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, @OutParameter IntBuffer values); } \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/GL33.java b/src/templates/org/lwjgl/opengl/GL33.java index 0a6330fb..e3de1df4 100644 --- a/src/templates/org/lwjgl/opengl/GL33.java +++ b/src/templates/org/lwjgl/opengl/GL33.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.ByteBuffer; import java.nio.FloatBuffer; @@ -100,7 +102,7 @@ public interface GL33 { void glDeleteSamplers(@AutoSize("samplers") @GLsizei int count, @Const @GLuint IntBuffer samplers); @Alternate("glDeleteSamplers") - void glDeleteSamplers(@Constant("1") @GLsizei int count, @Constant(value = "APIUtils.getBufferInt().put(0, sampler), 0", keepParam = true) int sampler); + void glDeleteSamplers(@Constant("1") @GLsizei int count, @Constant(value = "APIUtil.getBufferInt().put(0, sampler), 0", keepParam = true) int sampler); boolean glIsSampler(@GLuint int sampler); diff --git a/src/templates/org/lwjgl/opengl/GL40.java b/src/templates/org/lwjgl/opengl/GL40.java index cec7778f..a11ef8d1 100644 --- a/src/templates/org/lwjgl/opengl/GL40.java +++ b/src/templates/org/lwjgl/opengl/GL40.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.ByteBuffer; import java.nio.DoubleBuffer; @@ -401,7 +403,7 @@ public interface GL40 { void glDeleteTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @Const @GLuint IntBuffer ids); @Alternate("glDeleteTransformFeedbacks") - void glDeleteTransformFeedbacks(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, id), 0", keepParam = true) int id); + void glDeleteTransformFeedbacks(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, id), 0", keepParam = true) int id); void glGenTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids); diff --git a/src/templates/org/lwjgl/opengl/GL41.java b/src/templates/org/lwjgl/opengl/GL41.java index b7592863..9249e4c5 100644 --- a/src/templates/org/lwjgl/opengl/GL41.java +++ b/src/templates/org/lwjgl/opengl/GL41.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; @@ -153,14 +154,14 @@ public interface GL41 { @StripPostfix(value = "strings", postfix = "v") @GLuint int glCreateShaderProgramv(@GLenum int type, @Constant("strings.length") @GLsizei int count, - @Const @NullTerminated @StringList(value = "count") CharSequence[] strings); + @Const @NullTerminated @PointerArray(value = "count") CharSequence[] strings); void glBindProgramPipeline(@GLuint int pipeline); void glDeleteProgramPipelines(@AutoSize("pipelines") @GLsizei int n, @Const @GLuint IntBuffer pipelines); @Alternate("glDeleteProgramPipelines") - void glDeleteProgramPipelines(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, pipeline), 0", keepParam = true) int pipeline); + void glDeleteProgramPipelines(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, pipeline), 0", keepParam = true) int pipeline); void glGenProgramPipelines(@AutoSize("pipelines") @GLsizei int n, @OutParameter @GLuint IntBuffer pipelines); diff --git a/src/templates/org/lwjgl/opengl/GREMEDY_string_marker.java b/src/templates/org/lwjgl/opengl/GREMEDY_string_marker.java index 465ba27c..fda16984 100644 --- a/src/templates/org/lwjgl/opengl/GREMEDY_string_marker.java +++ b/src/templates/org/lwjgl/opengl/GREMEDY_string_marker.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.GLsizei; import java.nio.ByteBuffer; diff --git a/src/templates/org/lwjgl/opengl/NV_conditional_render.java b/src/templates/org/lwjgl/opengl/NV_conditional_render.java index 61c13946..a562316e 100644 --- a/src/templates/org/lwjgl/opengl/NV_conditional_render.java +++ b/src/templates/org/lwjgl/opengl/NV_conditional_render.java @@ -31,8 +31,8 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLenum; -import org.lwjgl.util.generator.GLuint; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLuint; public interface NV_conditional_render { diff --git a/src/templates/org/lwjgl/opengl/NV_copy_image.java b/src/templates/org/lwjgl/opengl/NV_copy_image.java index c70f47b5..9abdd424 100644 --- a/src/templates/org/lwjgl/opengl/NV_copy_image.java +++ b/src/templates/org/lwjgl/opengl/NV_copy_image.java @@ -31,9 +31,9 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLenum; -import org.lwjgl.util.generator.GLsizei; -import org.lwjgl.util.generator.GLuint; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; public interface NV_copy_image { diff --git a/src/templates/org/lwjgl/opengl/NV_evaluators.java b/src/templates/org/lwjgl/opengl/NV_evaluators.java index 97455001..ec962d70 100644 --- a/src/templates/org/lwjgl/opengl/NV_evaluators.java +++ b/src/templates/org/lwjgl/opengl/NV_evaluators.java @@ -32,6 +32,10 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLfloat; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/NV_explicit_multisample.java b/src/templates/org/lwjgl/opengl/NV_explicit_multisample.java index 4e125458..fb5c05b7 100644 --- a/src/templates/org/lwjgl/opengl/NV_explicit_multisample.java +++ b/src/templates/org/lwjgl/opengl/NV_explicit_multisample.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.ByteBuffer; import java.nio.FloatBuffer; @@ -75,17 +77,21 @@ public interface NV_explicit_multisample { int GL_INT_SAMPLER_RENDERBUFFER_NV = 0x8E57; int GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV = 0x8E58; + @Reuse("EXTDrawBuffers2") @StripPostfix(value = "data", extension = "EXT") - void glGetBooleanIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") @GLboolean ByteBuffer data); + void glGetBooleanIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("4") @GLboolean ByteBuffer data); + @Reuse("EXTDrawBuffers2") @Alternate("glGetBooleanIndexedvEXT") @GLreturn("data") @StripPostfix(value = "data", extension = "EXT") void glGetBooleanIndexedvEXT2(@GLenum int pname, @GLuint int index, @OutParameter @GLboolean ByteBuffer data); + @Reuse("EXTDrawBuffers2") @StripPostfix(value = "data", extension = "EXT") void glGetIntegerIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") IntBuffer data); + @Reuse("EXTDrawBuffers2") @Alternate("glGetIntegerIndexedvEXT") @GLreturn("data") @StripPostfix(value = "data", extension = "EXT") diff --git a/src/templates/org/lwjgl/opengl/NV_fence.java b/src/templates/org/lwjgl/opengl/NV_fence.java index a5a5e89d..981c2689 100644 --- a/src/templates/org/lwjgl/opengl/NV_fence.java +++ b/src/templates/org/lwjgl/opengl/NV_fence.java @@ -32,6 +32,11 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLreturn; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.*; @@ -49,7 +54,7 @@ public interface NV_fence { void glDeleteFencesNV(@AutoSize("piFences") @GLsizei int n, @Const @GLuint IntBuffer piFences); @Alternate("glDeleteFencesNV") - void glDeleteFencesNV(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtils.getBufferInt().put(0, fence), 0", keepParam = true) int fence); + void glDeleteFencesNV(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtil.getBufferInt().put(0, fence), 0", keepParam = true) int fence); void glSetFenceNV(@GLuint int fence, @GLenum int condition); diff --git a/src/templates/org/lwjgl/opengl/NV_fragment_program.java b/src/templates/org/lwjgl/opengl/NV_fragment_program.java index 3af35044..9ecba8ff 100644 --- a/src/templates/org/lwjgl/opengl/NV_fragment_program.java +++ b/src/templates/org/lwjgl/opengl/NV_fragment_program.java @@ -32,6 +32,9 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLubyte; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/NV_framebuffer_multisample_coverage.java b/src/templates/org/lwjgl/opengl/NV_framebuffer_multisample_coverage.java index 3a1bb85d..d90b9a1e 100644 --- a/src/templates/org/lwjgl/opengl/NV_framebuffer_multisample_coverage.java +++ b/src/templates/org/lwjgl/opengl/NV_framebuffer_multisample_coverage.java @@ -31,8 +31,8 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLenum; -import org.lwjgl.util.generator.GLsizei; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLsizei; public interface NV_framebuffer_multisample_coverage { diff --git a/src/templates/org/lwjgl/opengl/NV_geometry_program4.java b/src/templates/org/lwjgl/opengl/NV_geometry_program4.java index 8db5045a..2749c2b0 100644 --- a/src/templates/org/lwjgl/opengl/NV_geometry_program4.java +++ b/src/templates/org/lwjgl/opengl/NV_geometry_program4.java @@ -31,8 +31,9 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.GLenum; -import org.lwjgl.util.generator.GLuint; +import org.lwjgl.util.generator.Reuse; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLuint; public interface NV_geometry_program4 { @@ -49,10 +50,13 @@ public interface NV_geometry_program4 { void glProgramVertexLimitNV(@GLenum int target, int limit); + @Reuse("EXTGeometryShader4") void glFramebufferTextureEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level); + @Reuse("EXTGeometryShader4") void glFramebufferTextureLayerEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer); + @Reuse("EXTGeometryShader4") void glFramebufferTextureFaceEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, @GLenum int face); } \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_gpu_program4.java b/src/templates/org/lwjgl/opengl/NV_gpu_program4.java index 6275ca28..32627189 100644 --- a/src/templates/org/lwjgl/opengl/NV_gpu_program4.java +++ b/src/templates/org/lwjgl/opengl/NV_gpu_program4.java @@ -32,6 +32,9 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.IntBuffer; diff --git a/src/templates/org/lwjgl/opengl/NV_gpu_shader5.java b/src/templates/org/lwjgl/opengl/NV_gpu_shader5.java index f81c43c6..3b4a8994 100644 --- a/src/templates/org/lwjgl/opengl/NV_gpu_shader5.java +++ b/src/templates/org/lwjgl/opengl/NV_gpu_shader5.java @@ -32,6 +32,10 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLint64EXT; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; +import org.lwjgl.util.generator.opengl.GLuint64EXT; import java.nio.LongBuffer; @@ -84,16 +88,16 @@ public interface NV_gpu_shader5 { void glUniform4i64NV(int location, @GLint64EXT long x, @GLint64EXT long y, @GLint64EXT long z, @GLint64EXT long w); @StripPostfix("value") - void glUniform1i64vNV(int location, @GLsizei int count, @Const @GLint64EXT @Check("1") LongBuffer value); + void glUniform1i64vNV(int location, @AutoSize("value") @GLsizei int count, @Const @GLint64EXT LongBuffer value); @StripPostfix("value") - void glUniform2i64vNV(int location, @GLsizei int count, @Const @GLint64EXT @Check("2") LongBuffer value); + void glUniform2i64vNV(int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const @GLint64EXT LongBuffer value); @StripPostfix("value") - void glUniform3i64vNV(int location, @GLsizei int count, @Const @GLint64EXT @Check("3") LongBuffer value); + void glUniform3i64vNV(int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const @GLint64EXT LongBuffer value); @StripPostfix("value") - void glUniform4i64vNV(int location, @GLsizei int count, @Const @GLint64EXT @Check("4") LongBuffer value); + void glUniform4i64vNV(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const @GLint64EXT LongBuffer value); void glUniform1ui64NV(int location, @GLuint64EXT long x); @@ -104,22 +108,22 @@ public interface NV_gpu_shader5 { void glUniform4ui64NV(int location, @GLuint64EXT long x, @GLuint64EXT long y, @GLuint64EXT long z, @GLuint64EXT long w); @StripPostfix("value") - void glUniform1ui64vNV(int location, @GLsizei int count, @Const @GLuint64EXT @Check("1") LongBuffer value); + void glUniform1ui64vNV(int location, @AutoSize("value") @GLsizei int count, @Const @GLuint64EXT LongBuffer value); @StripPostfix("value") - void glUniform2ui64vNV(int location, @GLsizei int count, @Const @GLuint64EXT @Check("2") LongBuffer value); + void glUniform2ui64vNV(int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const @GLuint64EXT LongBuffer value); @StripPostfix("value") - void glUniform3ui64vNV(int location, @GLsizei int count, @Const @GLuint64EXT @Check("3") LongBuffer value); + void glUniform3ui64vNV(int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const @GLuint64EXT LongBuffer value); @StripPostfix("value") - void glUniform4ui64vNV(int location, @GLsizei int count, @Const @GLuint64EXT @Check("4") LongBuffer value); + void glUniform4ui64vNV(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const @GLuint64EXT LongBuffer value); @StripPostfix("params") - void glGetUniformi64vNV(@GLuint int program, int location, @GLint64EXT @Check LongBuffer params); + void glGetUniformi64vNV(@GLuint int program, int location, @OutParameter @Check("1") @GLint64EXT LongBuffer params); @StripPostfix("params") - void glGetUniformui64vNV(@GLuint int program, int location, @GLuint64EXT @Check LongBuffer params); + void glGetUniformui64vNV(@GLuint int program, int location, @OutParameter @Check("1") @GLuint64EXT LongBuffer params); // ------------- @@ -137,19 +141,19 @@ public interface NV_gpu_shader5 { @Dependent("EXT_direct_state_access") @StripPostfix("value") - void glProgramUniform1i64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLint64EXT @Check("1") LongBuffer value); + void glProgramUniform1i64vNV(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const @GLint64EXT LongBuffer value); @Dependent("EXT_direct_state_access") @StripPostfix("value") - void glProgramUniform2i64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLint64EXT @Check("2") LongBuffer value); + void glProgramUniform2i64vNV(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const @GLint64EXT LongBuffer value); @Dependent("EXT_direct_state_access") @StripPostfix("value") - void glProgramUniform3i64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLint64EXT @Check("3") LongBuffer value); + void glProgramUniform3i64vNV(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const @GLint64EXT LongBuffer value); @Dependent("EXT_direct_state_access") @StripPostfix("value") - void glProgramUniform4i64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLint64EXT @Check("4") LongBuffer value); + void glProgramUniform4i64vNV(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const @GLint64EXT LongBuffer value); @Dependent("EXT_direct_state_access") void glProgramUniform1ui64NV(@GLuint int program, int location, @GLuint64EXT long x); @@ -165,18 +169,18 @@ public interface NV_gpu_shader5 { @Dependent("EXT_direct_state_access") @StripPostfix("value") - void glProgramUniform1ui64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLuint64EXT @Check("1") LongBuffer value); + void glProgramUniform1ui64vNV(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const @GLuint64EXT LongBuffer value); @Dependent("EXT_direct_state_access") @StripPostfix("value") - void glProgramUniform2ui64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLuint64EXT @Check("2") LongBuffer value); + void glProgramUniform2ui64vNV(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const @GLuint64EXT LongBuffer value); @Dependent("EXT_direct_state_access") @StripPostfix("value") - void glProgramUniform3ui64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLuint64EXT @Check("3") LongBuffer value); + void glProgramUniform3ui64vNV(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const @GLuint64EXT LongBuffer value); @Dependent("EXT_direct_state_access") @StripPostfix("value") - void glProgramUniform4ui64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLuint64EXT @Check("4") LongBuffer value); + void glProgramUniform4ui64vNV(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const @GLuint64EXT LongBuffer value); } \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_half_float.java b/src/templates/org/lwjgl/opengl/NV_half_float.java index 134c61bc..1a48662c 100644 --- a/src/templates/org/lwjgl/opengl/NV_half_float.java +++ b/src/templates/org/lwjgl/opengl/NV_half_float.java @@ -32,6 +32,10 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLhalf; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/NV_occlusion_query.java b/src/templates/org/lwjgl/opengl/NV_occlusion_query.java index bfafdb6b..5fb3092d 100644 --- a/src/templates/org/lwjgl/opengl/NV_occlusion_query.java +++ b/src/templates/org/lwjgl/opengl/NV_occlusion_query.java @@ -32,6 +32,11 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLreturn; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.IntBuffer; @@ -54,7 +59,7 @@ public interface NV_occlusion_query { void glDeleteOcclusionQueriesNV(@AutoSize("piIDs") @GLsizei int n, @Const @GLuint IntBuffer piIDs); @Alternate("glDeleteOcclusionQueriesNV") - void glDeleteOcclusionQueriesNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, piID), 0", keepParam = true) int piID); + void glDeleteOcclusionQueriesNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, piID), 0", keepParam = true) int piID); boolean glIsOcclusionQueryNV(@GLuint int id); diff --git a/src/templates/org/lwjgl/opengl/NV_parameter_buffer_object.java b/src/templates/org/lwjgl/opengl/NV_parameter_buffer_object.java index d7c39da1..dea16c89 100644 --- a/src/templates/org/lwjgl/opengl/NV_parameter_buffer_object.java +++ b/src/templates/org/lwjgl/opengl/NV_parameter_buffer_object.java @@ -32,6 +32,9 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.FloatBuffer; import java.nio.IntBuffer; diff --git a/src/templates/org/lwjgl/opengl/NV_pixel_data_range.java b/src/templates/org/lwjgl/opengl/NV_pixel_data_range.java index 4cadda3f..9749210c 100644 --- a/src/templates/org/lwjgl/opengl/NV_pixel_data_range.java +++ b/src/templates/org/lwjgl/opengl/NV_pixel_data_range.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/NV_point_sprite.java b/src/templates/org/lwjgl/opengl/NV_point_sprite.java index 17958db6..a5b52f04 100644 --- a/src/templates/org/lwjgl/opengl/NV_point_sprite.java +++ b/src/templates/org/lwjgl/opengl/NV_point_sprite.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/NV_primitive_restart.java b/src/templates/org/lwjgl/opengl/NV_primitive_restart.java index d521de67..5471cf27 100644 --- a/src/templates/org/lwjgl/opengl/NV_primitive_restart.java +++ b/src/templates/org/lwjgl/opengl/NV_primitive_restart.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLuint; @ForceInit public interface NV_primitive_restart { diff --git a/src/templates/org/lwjgl/opengl/NV_program.java b/src/templates/org/lwjgl/opengl/NV_program.java index 9cb9f87b..9709bad3 100644 --- a/src/templates/org/lwjgl/opengl/NV_program.java +++ b/src/templates/org/lwjgl/opengl/NV_program.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.Buffer; import java.nio.ByteBuffer; @@ -67,7 +69,7 @@ public interface NV_program { void glDeleteProgramsNV(@AutoSize("programs") @GLsizei int n, @Const @GLuint IntBuffer programs); @Alternate("glDeleteProgramsNV") - void glDeleteProgramsNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, program), 0", keepParam = true) int program); + void glDeleteProgramsNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, program), 0", keepParam = true) int program); void glGenProgramsNV(@AutoSize("programs") @GLsizei int n, @OutParameter @GLuint IntBuffer programs); @@ -99,6 +101,6 @@ public interface NV_program { void glRequestResidentProgramsNV(@AutoSize("programIDs") @GLsizei int n, @GLuint IntBuffer programIDs); @Alternate("glRequestResidentProgramsNV") - void glRequestResidentProgramsNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, programID), 0", keepParam = true) int programID); + void glRequestResidentProgramsNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, programID), 0", keepParam = true) int programID); } diff --git a/src/templates/org/lwjgl/opengl/NV_register_combiners.java b/src/templates/org/lwjgl/opengl/NV_register_combiners.java index 19e389a5..16c2f850 100644 --- a/src/templates/org/lwjgl/opengl/NV_register_combiners.java +++ b/src/templates/org/lwjgl/opengl/NV_register_combiners.java @@ -32,6 +32,9 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLreturn; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/NV_register_combiners2.java b/src/templates/org/lwjgl/opengl/NV_register_combiners2.java index fd39f738..237d296b 100644 --- a/src/templates/org/lwjgl/opengl/NV_register_combiners2.java +++ b/src/templates/org/lwjgl/opengl/NV_register_combiners2.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.GLenum; import java.nio.*; diff --git a/src/templates/org/lwjgl/opengl/NV_shader_buffer_load.java b/src/templates/org/lwjgl/opengl/NV_shader_buffer_load.java index 6c1e5c81..26d526a5 100644 --- a/src/templates/org/lwjgl/opengl/NV_shader_buffer_load.java +++ b/src/templates/org/lwjgl/opengl/NV_shader_buffer_load.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.LongBuffer; @@ -90,6 +92,7 @@ public interface NV_shader_buffer_load { @StripPostfix("value") void glUniformui64vNV(int location, @AutoSize("value") @GLsizei int count, @Const @GLuint64EXT LongBuffer value); + @Reuse("NVGpuShader5") @StripPostfix("params") void glGetUniformui64vNV(@GLuint int program, int location, @OutParameter @Check("1") @GLuint64EXT LongBuffer params); diff --git a/src/templates/org/lwjgl/opengl/NV_transform_feedback.java b/src/templates/org/lwjgl/opengl/NV_transform_feedback.java index b0e72e27..ee8d6269 100644 --- a/src/templates/org/lwjgl/opengl/NV_transform_feedback.java +++ b/src/templates/org/lwjgl/opengl/NV_transform_feedback.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.ByteBuffer; import java.nio.IntBuffer; @@ -150,7 +152,7 @@ public interface NV_transform_feedback { @Alternate(value = "glGetActiveVaryingNV", javaAlt = true) @GLreturn(value = "name", maxLength = "bufSize") void glGetActiveVaryingNV(@GLuint int program, @GLuint int index, @GLsizei int bufSize, - @OutParameter @GLsizei @Constant("name_length, 0, APIUtils.getBufferInt(), 0, APIUtils.getBufferInt(), 1") IntBuffer length, + @OutParameter @GLsizei @Constant("name_length, 0, APIUtil.getBufferInt(), 0, APIUtil.getBufferInt(), 1") IntBuffer length, @OutParameter @GLchar ByteBuffer name); /** Overloads glGetActiveVaryingNV. This version returns only the varying size. */ @@ -160,7 +162,7 @@ public interface NV_transform_feedback { @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, @OutParameter IntBuffer size, @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore - @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name); + @OutParameter @GLchar @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name); /** Overloads glGetActiveVaryingNV. This version returns only the varying type. */ @Alternate(value = "glGetActiveVaryingNV", javaAlt = true) @@ -169,7 +171,7 @@ public interface NV_transform_feedback { @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore @OutParameter @GLenum IntBuffer type, - @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name); + @OutParameter @GLchar @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name); void glActiveVaryingNV(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name); diff --git a/src/templates/org/lwjgl/opengl/NV_transform_feedback2.java b/src/templates/org/lwjgl/opengl/NV_transform_feedback2.java index 5a55be48..32c7f98a 100644 --- a/src/templates/org/lwjgl/opengl/NV_transform_feedback2.java +++ b/src/templates/org/lwjgl/opengl/NV_transform_feedback2.java @@ -32,6 +32,11 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.GLenum; +import org.lwjgl.util.generator.opengl.GLreturn; +import org.lwjgl.util.generator.opengl.GLsizei; +import org.lwjgl.util.generator.opengl.GLuint; import java.nio.IntBuffer; @@ -54,7 +59,7 @@ public interface NV_transform_feedback2 { void glDeleteTransformFeedbacksNV(@AutoSize("ids") @GLsizei int n, @Const @GLuint IntBuffer ids); @Alternate("glDeleteTransformFeedbacksNV") - void glDeleteTransformFeedbacksNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, id), 0", keepParam = true) int id); + void glDeleteTransformFeedbacksNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, id), 0", keepParam = true) int id); void glGenTransformFeedbacksNV(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids); diff --git a/src/templates/org/lwjgl/opengl/NV_vertex_array_range.java b/src/templates/org/lwjgl/opengl/NV_vertex_array_range.java index f4b995bd..f8995be0 100644 --- a/src/templates/org/lwjgl/opengl/NV_vertex_array_range.java +++ b/src/templates/org/lwjgl/opengl/NV_vertex_array_range.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.*; @@ -54,7 +55,7 @@ public interface NV_vertex_array_range { @PlatformDependent({Platform.WGL, Platform.GLX}) @GLvoid - @AutoResultSize("size") + @AutoSize("size") ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority); @PlatformDependent({Platform.WGL, Platform.GLX}) diff --git a/src/templates/org/lwjgl/opengl/NV_vertex_attrib_integer_64bit.java b/src/templates/org/lwjgl/opengl/NV_vertex_attrib_integer_64bit.java index 5558afcc..7c10430f 100644 --- a/src/templates/org/lwjgl/opengl/NV_vertex_attrib_integer_64bit.java +++ b/src/templates/org/lwjgl/opengl/NV_vertex_attrib_integer_64bit.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.LongBuffer; diff --git a/src/templates/org/lwjgl/opengl/NV_vertex_buffer_unified_memory.java b/src/templates/org/lwjgl/opengl/NV_vertex_buffer_unified_memory.java index 0b5f77e1..b366b27e 100644 --- a/src/templates/org/lwjgl/opengl/NV_vertex_buffer_unified_memory.java +++ b/src/templates/org/lwjgl/opengl/NV_vertex_buffer_unified_memory.java @@ -32,6 +32,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.opengl.*; import java.nio.LongBuffer; diff --git a/src/templates/org/lwjgl/opengl/NV_vertex_program.java b/src/templates/org/lwjgl/opengl/NV_vertex_program.java index e9606851..69fc7e37 100644 --- a/src/templates/org/lwjgl/opengl/NV_vertex_program.java +++ b/src/templates/org/lwjgl/opengl/NV_vertex_program.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; import java.nio.*;