rusticl/gl: make GLX support optional
Signed-off-by: Karol Herbst <kherbst@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26394>
This commit is contained in:
@@ -2015,6 +2015,9 @@ if with_platform_x11
|
|||||||
dep_xfixes = dependency('xfixes', version : '>= 2.0')
|
dep_xfixes = dependency('xfixes', version : '>= 2.0')
|
||||||
dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
|
dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
|
||||||
dep_xcb_shm = dependency('xcb-shm')
|
dep_xcb_shm = dependency('xcb-shm')
|
||||||
|
elif with_gallium_rusticl
|
||||||
|
# needed for GL sharing extension
|
||||||
|
dep_x11 = dependency('x11')
|
||||||
endif
|
endif
|
||||||
if (with_any_vk or with_glx == 'dri' or with_egl or
|
if (with_any_vk or with_glx == 'dri' or with_egl or
|
||||||
(with_gallium_vdpau or with_gallium_va or
|
(with_gallium_vdpau or with_gallium_va or
|
||||||
@@ -2069,9 +2072,6 @@ if with_platform_x11
|
|||||||
if with_xlib_lease
|
if with_xlib_lease
|
||||||
dep_xlib_xrandr = dependency('xrandr', version : '>= 1.3')
|
dep_xlib_xrandr = dependency('xrandr', version : '>= 1.3')
|
||||||
endif
|
endif
|
||||||
elif with_gallium_rusticl
|
|
||||||
# needed for GL sharing extension
|
|
||||||
dep_x11 = dependency('x11')
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if with_dri
|
if with_dri
|
||||||
|
@@ -16,6 +16,7 @@ use mesa_rust::pipe::resource::*;
|
|||||||
use mesa_rust::pipe::screen::*;
|
use mesa_rust::pipe::screen::*;
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::ffi::CStr;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
@@ -25,6 +26,7 @@ use std::sync::Arc;
|
|||||||
type CLGLMappings = Option<HashMap<Arc<PipeResource>, Arc<PipeResource>>>;
|
type CLGLMappings = Option<HashMap<Arc<PipeResource>, Arc<PipeResource>>>;
|
||||||
|
|
||||||
pub struct XPlatManager {
|
pub struct XPlatManager {
|
||||||
|
#[cfg(glx)]
|
||||||
glx_get_proc_addr: PFNGLXGETPROCADDRESSPROC,
|
glx_get_proc_addr: PFNGLXGETPROCADDRESSPROC,
|
||||||
egl_get_proc_addr: PFNEGLGETPROCADDRESSPROC,
|
egl_get_proc_addr: PFNEGLGETPROCADDRESSPROC,
|
||||||
}
|
}
|
||||||
@@ -38,6 +40,7 @@ impl Default for XPlatManager {
|
|||||||
impl XPlatManager {
|
impl XPlatManager {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
#[cfg(glx)]
|
||||||
glx_get_proc_addr: Self::get_proc_address_func("glXGetProcAddress"),
|
glx_get_proc_addr: Self::get_proc_address_func("glXGetProcAddress"),
|
||||||
egl_get_proc_addr: Self::get_proc_address_func("eglGetProcAddress"),
|
egl_get_proc_addr: Self::get_proc_address_func("eglGetProcAddress"),
|
||||||
}
|
}
|
||||||
@@ -51,14 +54,28 @@ impl XPlatManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(glx)]
|
||||||
|
unsafe fn get_func_glx(&self, cname: &CStr) -> CLResult<__GLXextFuncPtr> {
|
||||||
|
unsafe {
|
||||||
|
Ok(self
|
||||||
|
.glx_get_proc_addr
|
||||||
|
.ok_or(CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR)?(
|
||||||
|
cname.as_ptr().cast(),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// in theory it should return CLResult<__GLXextFuncPtr> but luckily it's identical
|
||||||
|
#[cfg(not(glx))]
|
||||||
|
unsafe fn get_func_glx(&self, _: &CStr) -> CLResult<__eglMustCastToProperFunctionPointerType> {
|
||||||
|
Err(CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR)
|
||||||
|
}
|
||||||
|
|
||||||
fn get_func<T>(&self, name: &str) -> CLResult<T> {
|
fn get_func<T>(&self, name: &str) -> CLResult<T> {
|
||||||
let cname = CString::new(name).unwrap();
|
let cname = CString::new(name).unwrap();
|
||||||
unsafe {
|
unsafe {
|
||||||
let raw_func = if name.starts_with("glX") {
|
let raw_func = if name.starts_with("glX") {
|
||||||
self.glx_get_proc_addr
|
self.get_func_glx(&cname)?
|
||||||
.ok_or(CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR)?(
|
|
||||||
cname.as_ptr().cast()
|
|
||||||
)
|
|
||||||
} else if name.starts_with("egl") {
|
} else if name.starts_with("egl") {
|
||||||
self.egl_get_proc_addr
|
self.egl_get_proc_addr
|
||||||
.ok_or(CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR)?(
|
.ok_or(CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR)?(
|
||||||
@@ -160,7 +177,7 @@ impl GLCtxManager {
|
|||||||
interop_dev_info: info,
|
interop_dev_info: info,
|
||||||
xplat_manager: xplat_manager,
|
xplat_manager: xplat_manager,
|
||||||
}))
|
}))
|
||||||
} else if !glx_display.is_null() {
|
} else if !glx_display.is_null() && cfg!(glx) {
|
||||||
let glx_query_device_info_func = xplat_manager
|
let glx_query_device_info_func = xplat_manager
|
||||||
.MesaGLInteropGLXQueryDeviceInfo()?
|
.MesaGLInteropGLXQueryDeviceInfo()?
|
||||||
.ok_or(CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR)?;
|
.ok_or(CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR)?;
|
||||||
|
@@ -92,6 +92,12 @@ rusticl_args = [
|
|||||||
'-Aclippy::type_complexity',
|
'-Aclippy::type_complexity',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if with_platform_x11
|
||||||
|
rusticl_args += [
|
||||||
|
'--cfg', 'glx',
|
||||||
|
]
|
||||||
|
endif
|
||||||
|
|
||||||
rusticl_gen_args = [
|
rusticl_gen_args = [
|
||||||
# can't do anything about it anyway
|
# can't do anything about it anyway
|
||||||
'-Aclippy::all',
|
'-Aclippy::all',
|
||||||
@@ -159,6 +165,7 @@ rusticl_opencl_bindings_rs = rust.bindgen(
|
|||||||
],
|
],
|
||||||
c_args : [
|
c_args : [
|
||||||
rusticl_bindgen_c_args,
|
rusticl_bindgen_c_args,
|
||||||
|
pre_args,
|
||||||
cl_c_args,
|
cl_c_args,
|
||||||
],
|
],
|
||||||
args : [
|
args : [
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
#include <CL/cl_icd.h>
|
#include <CL/cl_icd.h>
|
||||||
#include <EGL/egl.h>
|
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
#include <EGL/egl.h>
|
||||||
|
#ifdef HAVE_X11_PLATFORM
|
||||||
#include <GL/glx.h>
|
#include <GL/glx.h>
|
||||||
|
#endif
|
||||||
#include "GL/mesa_glinterop.h"
|
#include "GL/mesa_glinterop.h"
|
||||||
|
|
||||||
#define DECL_CL_STRUCT(name) struct name { const cl_icd_dispatch *dispatch; }
|
#define DECL_CL_STRUCT(name) struct name { const cl_icd_dispatch *dispatch; }
|
||||||
|
Reference in New Issue
Block a user