stabilize build system: depends, installer, boost/bdb fixes, cross targets groundwork

This commit is contained in:
2026-02-24 18:38:47 +00:00
parent da8c28aaeb
commit 65cb2619a7
13106 changed files with 2484322 additions and 1804 deletions
@@ -0,0 +1,100 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
// See http://boostorg.github.com/compute for more information.
//---------------------------------------------------------------------------//
#ifndef BOOST_COMPUTE_INTEROP_OPENGL_ACQUIRE_HPP
#define BOOST_COMPUTE_INTEROP_OPENGL_ACQUIRE_HPP
#include <boost/compute/command_queue.hpp>
#include <boost/compute/interop/opengl/cl_gl.hpp>
#include <boost/compute/interop/opengl/opengl_buffer.hpp>
#include <boost/compute/types/fundamental.hpp>
#include <boost/compute/utility/wait_list.hpp>
namespace boost {
namespace compute {
/// Enqueues a command to acquire the specified OpenGL memory objects.
///
/// \see_opencl_ref{clEnqueueAcquireGLObjects}
inline event opengl_enqueue_acquire_gl_objects(const uint_ num_objects,
const cl_mem *mem_objects,
command_queue &queue,
const wait_list &events = wait_list())
{
BOOST_ASSERT(queue != 0);
event event_;
cl_int ret = clEnqueueAcquireGLObjects(queue.get(),
num_objects,
mem_objects,
events.size(),
events.get_event_ptr(),
&event_.get());
if(ret != CL_SUCCESS){
BOOST_THROW_EXCEPTION(opencl_error(ret));
}
return event_;
}
/// Enqueues a command to release the specified OpenGL memory objects.
///
/// \see_opencl_ref{clEnqueueReleaseGLObjects}
inline event opengl_enqueue_release_gl_objects(const uint_ num_objects,
const cl_mem *mem_objects,
command_queue &queue,
const wait_list &events = wait_list())
{
BOOST_ASSERT(queue != 0);
event event_;
cl_int ret = clEnqueueReleaseGLObjects(queue.get(),
num_objects,
mem_objects,
events.size(),
events.get_event_ptr(),
&event_.get());
if(ret != CL_SUCCESS){
BOOST_THROW_EXCEPTION(opencl_error(ret));
}
return event_;
}
/// Enqueues a command to acquire the specified OpenGL buffer.
///
/// \see_opencl_ref{clEnqueueAcquireGLObjects}
inline event opengl_enqueue_acquire_buffer(const opengl_buffer &buffer,
command_queue &queue,
const wait_list &events = wait_list())
{
BOOST_ASSERT(buffer.get_context() == queue.get_context());
return opengl_enqueue_acquire_gl_objects(1, &buffer.get(), queue, events);
}
/// Enqueues a command to release the specified OpenGL buffer.
///
/// \see_opencl_ref{clEnqueueReleaseGLObjects}
inline event opengl_enqueue_release_buffer(const opengl_buffer &buffer,
command_queue &queue,
const wait_list &events = wait_list())
{
BOOST_ASSERT(buffer.get_context() == queue.get_context());
return opengl_enqueue_release_gl_objects(1, &buffer.get(), queue, events);
}
} // end compute namespace
} // end boost namespace
#endif // BOOST_COMPUTE_INTEROP_OPENGL_ACQUIRE_HPP
@@ -0,0 +1,20 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
// See http://boostorg.github.com/compute for more information.
//---------------------------------------------------------------------------//
#ifndef BOOST_COMPUTE_INTEROP_OPENGL_CL_GL_HPP
#define BOOST_COMPUTE_INTEROP_OPENGL_CL_GL_HPP
#if defined(__APPLE__)
#include <OpenCL/cl_gl.h>
#else
#include <CL/cl_gl.h>
#endif
#endif // BOOST_COMPUTE_INTEROP_OPENGL_CL_GL_HPP
@@ -0,0 +1,20 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
// See http://boostorg.github.com/compute for more information.
//---------------------------------------------------------------------------//
#ifndef BOOST_COMPUTE_INTEROP_OPENGL_CL_GL_EXT_HPP
#define BOOST_COMPUTE_INTEROP_OPENGL_CL_GL_EXT_HPP
#if defined(__APPLE__)
#include <OpenCL/cl_gl_ext.h>
#else
#include <CL/cl_gl_ext.h>
#endif
#endif // BOOST_COMPUTE_INTEROP_OPENGL_CL_GL_EXT_HPP
@@ -0,0 +1,135 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
// See http://boostorg.github.com/compute for more information.
//---------------------------------------------------------------------------//
#ifndef BOOST_COMPUTE_INTEROP_OPENGL_CONTEXT_HPP
#define BOOST_COMPUTE_INTEROP_OPENGL_CONTEXT_HPP
#include <boost/throw_exception.hpp>
#include <boost/compute/device.hpp>
#include <boost/compute/system.hpp>
#include <boost/compute/context.hpp>
#include <boost/compute/exception/unsupported_extension_error.hpp>
#include <boost/compute/interop/opengl/cl_gl.hpp>
#ifdef __APPLE__
#include <OpenCL/cl_gl_ext.h>
#include <OpenGL/OpenGL.h>
#endif
#ifdef __linux__
#include <GL/glx.h>
#endif
namespace boost {
namespace compute {
/// Creates a shared OpenCL/OpenGL context for the currently active
/// OpenGL context.
///
/// Once created, the shared context can be used to create OpenCL memory
/// objects which can interact with OpenGL memory objects (e.g. VBOs).
///
/// \throws unsupported_extension_error if no CL-GL sharing capable devices
/// are found.
inline context opengl_create_shared_context()
{
// name of the OpenGL sharing extension for the system
#if defined(__APPLE__)
const char *cl_gl_sharing_extension = "cl_APPLE_gl_sharing";
#else
const char *cl_gl_sharing_extension = "cl_khr_gl_sharing";
#endif
#if defined(__APPLE__)
// get OpenGL share group
CGLContextObj cgl_current_context = CGLGetCurrentContext();
CGLShareGroupObj cgl_share_group = CGLGetShareGroup(cgl_current_context);
cl_context_properties properties[] = {
CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE,
(cl_context_properties) cgl_share_group,
0
};
cl_int error = 0;
cl_context cl_gl_context = clCreateContext(properties, 0, 0, 0, 0, &error);
if(!cl_gl_context){
BOOST_THROW_EXCEPTION(opencl_error(error));
}
return context(cl_gl_context, false);
#else
typedef cl_int(*GetGLContextInfoKHRFunction)(
const cl_context_properties*, cl_gl_context_info, size_t, void *, size_t *
);
std::vector<platform> platforms = system::platforms();
for(size_t i = 0; i < platforms.size(); i++){
const platform &platform = platforms[i];
// load clGetGLContextInfoKHR() extension function
GetGLContextInfoKHRFunction GetGLContextInfoKHR =
reinterpret_cast<GetGLContextInfoKHRFunction>(
reinterpret_cast<size_t>(
platform.get_extension_function_address("clGetGLContextInfoKHR")
)
);
if(!GetGLContextInfoKHR){
continue;
}
// create context properties listing the platform and current OpenGL display
cl_context_properties properties[] = {
CL_CONTEXT_PLATFORM, (cl_context_properties) platform.id(),
#if defined(__linux__)
CL_GL_CONTEXT_KHR, (cl_context_properties) glXGetCurrentContext(),
CL_GLX_DISPLAY_KHR, (cl_context_properties) glXGetCurrentDisplay(),
#elif defined(WIN32)
CL_GL_CONTEXT_KHR, (cl_context_properties) wglGetCurrentContext(),
CL_WGL_HDC_KHR, (cl_context_properties) wglGetCurrentDC(),
#endif
0
};
// lookup current OpenCL device for current OpenGL context
cl_device_id gpu_id;
cl_int ret = GetGLContextInfoKHR(
properties,
CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR,
sizeof(cl_device_id),
&gpu_id,
0
);
if(ret != CL_SUCCESS){
continue;
}
// create device object for the GPU and ensure it supports CL-GL sharing
device gpu(gpu_id, false);
if(!gpu.supports_extension(cl_gl_sharing_extension)){
continue;
}
// return CL-GL sharing context
return context(gpu, properties);
}
#endif
// no CL-GL sharing capable devices found
BOOST_THROW_EXCEPTION(
unsupported_extension_error(cl_gl_sharing_extension)
);
}
} // end compute namespace
} // end boost namespace
#endif // BOOST_COMPUTE_INTEROP_OPENGL_CONTEXT_HPP
@@ -0,0 +1,20 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
// See http://boostorg.github.com/compute for more information.
//---------------------------------------------------------------------------//
#ifndef BOOST_COMPUTE_INTEROP_OPENGL_GL_HPP
#define BOOST_COMPUTE_INTEROP_OPENGL_GL_HPP
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#endif // BOOST_COMPUTE_INTEROP_OPENGL_GL_HPP
@@ -0,0 +1,106 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
// See http://boostorg.github.com/compute for more information.
//---------------------------------------------------------------------------//
#ifndef BOOST_COMPUTE_INTEROP_OPENGL_OPENGL_BUFFER_HPP
#define BOOST_COMPUTE_INTEROP_OPENGL_OPENGL_BUFFER_HPP
#include <boost/compute/buffer.hpp>
#include <boost/compute/interop/opengl/gl.hpp>
#include <boost/compute/interop/opengl/cl_gl.hpp>
namespace boost {
namespace compute {
/// \class opengl_buffer
///
/// A OpenCL buffer for accessing an OpenGL memory object.
class opengl_buffer : public buffer
{
public:
/// Creates a null OpenGL buffer object.
opengl_buffer()
: buffer()
{
}
/// Creates a new OpenGL buffer object for \p mem.
explicit opengl_buffer(cl_mem mem, bool retain = true)
: buffer(mem, retain)
{
}
/// Creates a new OpenGL buffer object in \p context for \p bufobj
/// with \p flags.
///
/// \see_opencl_ref{clCreateFromGLBuffer}
opengl_buffer(const context &context,
GLuint bufobj,
cl_mem_flags flags = read_write)
{
cl_int error = 0;
m_mem = clCreateFromGLBuffer(context, flags, bufobj, &error);
if(!m_mem){
BOOST_THROW_EXCEPTION(opencl_error(error));
}
}
/// Creates a new OpenGL buffer object as a copy of \p other.
opengl_buffer(const opengl_buffer &other)
: buffer(other)
{
}
/// Copies the OpenGL buffer object from \p other.
opengl_buffer& operator=(const opengl_buffer &other)
{
if(this != &other){
buffer::operator=(other);
}
return *this;
}
/// Destroys the OpenGL buffer object.
~opengl_buffer()
{
}
/// Returns the OpenGL memory object ID.
///
/// \see_opencl_ref{clGetGLObjectInfo}
GLuint get_opengl_object() const
{
GLuint object = 0;
clGetGLObjectInfo(m_mem, 0, &object);
return object;
}
/// Returns the OpenGL memory object type.
///
/// \see_opencl_ref{clGetGLObjectInfo}
cl_gl_object_type get_opengl_type() const
{
cl_gl_object_type type;
clGetGLObjectInfo(m_mem, &type, 0);
return type;
}
};
namespace detail {
// set_kernel_arg specialization for opengl_buffer
template<>
struct set_kernel_arg<opengl_buffer> : set_kernel_arg<memory_object> { };
} // end detail namespace
} // end compute namespace
} // end boost namespace
#endif // BOOST_COMPUTE_INTEROP_OPENGL_OPENGL_BUFFER_HPP
@@ -0,0 +1,129 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
// See http://boostorg.github.com/compute for more information.
//---------------------------------------------------------------------------//
#ifndef BOOST_COMPUTE_INTEROP_OPENGL_OPENGL_RENDERBUFFER_HPP
#define BOOST_COMPUTE_INTEROP_OPENGL_OPENGL_RENDERBUFFER_HPP
#include <boost/compute/image/image_object.hpp>
#include <boost/compute/interop/opengl/gl.hpp>
#include <boost/compute/interop/opengl/cl_gl.hpp>
#include <boost/compute/type_traits/type_name.hpp>
#include <boost/compute/utility/extents.hpp>
namespace boost {
namespace compute {
/// \class opengl_renderbuffer
///
/// A OpenCL buffer for accessing an OpenGL renderbuffer object.
class opengl_renderbuffer : public image_object
{
public:
/// Creates a null OpenGL renderbuffer object.
opengl_renderbuffer()
: image_object()
{
}
/// Creates a new OpenGL renderbuffer object for \p mem.
explicit opengl_renderbuffer(cl_mem mem, bool retain = true)
: image_object(mem, retain)
{
}
/// Creates a new OpenGL renderbuffer object in \p context for
/// \p renderbuffer with \p flags.
///
/// \see_opencl_ref{clCreateFromGLRenderbuffer}
opengl_renderbuffer(const context &context,
GLuint renderbuffer,
cl_mem_flags flags = read_write)
{
cl_int error = 0;
m_mem = clCreateFromGLRenderbuffer(
context, flags, renderbuffer, &error
);
if(!m_mem){
BOOST_THROW_EXCEPTION(opencl_error(error));
}
}
/// Creates a new OpenGL renderbuffer object as a copy of \p other.
opengl_renderbuffer(const opengl_renderbuffer &other)
: image_object(other)
{
}
/// Copies the OpenGL renderbuffer object from \p other.
opengl_renderbuffer& operator=(const opengl_renderbuffer &other)
{
if(this != &other){
image_object::operator=(other);
}
return *this;
}
/// Destroys the OpenGL buffer object.
~opengl_renderbuffer()
{
}
/// Returns the size (width, height) of the renderbuffer.
extents<2> size() const
{
extents<2> size;
size[0] = get_image_info<size_t>(CL_IMAGE_WIDTH);
size[1] = get_image_info<size_t>(CL_IMAGE_HEIGHT);
return size;
}
/// Returns the origin of the renderbuffer (\c 0, \c 0).
extents<2> origin() const
{
return extents<2>();
}
/// Returns the OpenGL memory object ID.
///
/// \see_opencl_ref{clGetGLObjectInfo}
GLuint get_opengl_object() const
{
GLuint object = 0;
clGetGLObjectInfo(m_mem, 0, &object);
return object;
}
/// Returns the OpenGL memory object type.
///
/// \see_opencl_ref{clGetGLObjectInfo}
cl_gl_object_type get_opengl_type() const
{
cl_gl_object_type type;
clGetGLObjectInfo(m_mem, &type, 0);
return type;
}
};
namespace detail {
// set_kernel_arg() specialization for opengl_renderbuffer
template<>
struct set_kernel_arg<opengl_renderbuffer> : public set_kernel_arg<image_object> { };
} // end detail namespace
} // end compute namespace
} // end boost namespace
BOOST_COMPUTE_TYPE_NAME(boost::compute::opengl_renderbuffer, image2d_t)
#endif // BOOST_COMPUTE_INTEROP_OPENGL_OPENGL_RENDERBUFFER_HPP
@@ -0,0 +1,133 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
// See http://boostorg.github.com/compute for more information.
//---------------------------------------------------------------------------//
#ifndef BOOST_COMPUTE_INTEROP_OPENGL_OPENGL_TEXTURE_HPP
#define BOOST_COMPUTE_INTEROP_OPENGL_OPENGL_TEXTURE_HPP
#include <boost/compute/image/image_object.hpp>
#include <boost/compute/interop/opengl/gl.hpp>
#include <boost/compute/interop/opengl/cl_gl.hpp>
#include <boost/compute/detail/get_object_info.hpp>
#include <boost/compute/type_traits/type_name.hpp>
#include <boost/compute/utility/extents.hpp>
namespace boost {
namespace compute {
/// \class opengl_texture
///
/// A OpenCL image2d for accessing an OpenGL texture object.
class opengl_texture : public image_object
{
public:
/// Creates a null OpenGL texture object.
opengl_texture()
: image_object()
{
}
/// Creates a new OpenGL texture object for \p mem.
explicit opengl_texture(cl_mem mem, bool retain = true)
: image_object(mem, retain)
{
}
/// Creates a new OpenGL texture object in \p context for \p texture
/// with \p flags.
///
/// \see_opencl_ref{clCreateFromGLTexture}
opengl_texture(const context &context,
GLenum texture_target,
GLint miplevel,
GLuint texture,
cl_mem_flags flags = read_write)
{
cl_int error = 0;
#ifdef CL_VERSION_1_2
m_mem = clCreateFromGLTexture(context,
flags,
texture_target,
miplevel,
texture,
&error);
#else
m_mem = clCreateFromGLTexture2D(context,
flags,
texture_target,
miplevel,
texture,
&error);
#endif
if(!m_mem){
BOOST_THROW_EXCEPTION(opencl_error(error));
}
}
/// Creates a new OpenGL texture object as a copy of \p other.
opengl_texture(const opengl_texture &other)
: image_object(other)
{
}
/// Copies the OpenGL texture object from \p other.
opengl_texture& operator=(const opengl_texture &other)
{
if(this != &other){
image_object::operator=(other);
}
return *this;
}
/// Destroys the texture object.
~opengl_texture()
{
}
/// Returns the size (width, height) of the texture.
extents<2> size() const
{
extents<2> size;
size[0] = get_image_info<size_t>(CL_IMAGE_WIDTH);
size[1] = get_image_info<size_t>(CL_IMAGE_HEIGHT);
return size;
}
/// Returns the origin of the texture (\c 0, \c 0).
extents<2> origin() const
{
return extents<2>();
}
/// Returns information about the texture.
///
/// \see_opencl_ref{clGetGLTextureInfo}
template<class T>
T get_texture_info(cl_gl_texture_info info) const
{
return detail::get_object_info<T>(clGetGLTextureInfo, m_mem, info);
}
};
namespace detail {
// set_kernel_arg() specialization for opengl_texture
template<>
struct set_kernel_arg<opengl_texture> : public set_kernel_arg<image_object> { };
} // end detail namespace
} // end compute namespace
} // end boost namespace
BOOST_COMPUTE_TYPE_NAME(boost::compute::opengl_texture, image2d_t)
#endif // BOOST_COMPUTE_INTEROP_OPENGL_OPENGL_TEXTURE_HPP