rusticl/program: accept and ignore Intel's 4G memory flags

Some applications are making use of it whenever they identify an Intel
device.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38720>
This commit is contained in:
Karol Herbst 2025-11-29 00:44:22 +01:00 committed by Marge Bot
parent b09be51a25
commit d90fbdf4a5
4 changed files with 16 additions and 1 deletions

View file

@ -14,6 +14,7 @@ use crate::core::format::*;
use crate::core::gl::*;
use crate::core::memory::*;
use crate::core::queue::*;
use crate::rusticl_warn_once;
use mesa_rust_gen::pipe_fd_type;
use mesa_rust_util::properties::Properties;
@ -48,7 +49,8 @@ fn validate_mem_flags(flags: cl_mem_flags, validation: MemFlagValidationType) ->
| CL_MEM_WRITE_ONLY
| CL_MEM_READ_ONLY
| CL_MEM_KERNEL_READ_AND_WRITE
| CL_MEM_IMMUTABLE_EXT,
| CL_MEM_IMMUTABLE_EXT
| CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL,
);
if validation != MemFlagValidationType::Imported {
@ -66,6 +68,12 @@ fn validate_mem_flags(flags: cl_mem_flags, validation: MemFlagValidationType) ->
return Err(CL_INVALID_VALUE);
}
if flags & cl_bitfield::from(CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL) != 0 {
rusticl_warn_once!(
"Use of CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL detected. This flag is ignored and applications shouldn't use them with rusticl."
);
}
Ok(())
}

View file

@ -309,6 +309,8 @@ fn prepare_options(options: &str, dev: &Device) -> Vec<CString> {
"-cl-denorms-are-zero" => Some("-fdenormal-fp-math=positive-zero"),
// We can ignore it as long as we don't support ifp
"-cl-no-subgroup-ifp" => None,
// Some applications use this argument when they detect Intel hardware.
"-cl-intel-greater-than-4GB-buffer-required" => None,
_ => Some(a),
})
.map(CString::new)

View file

@ -136,6 +136,8 @@ rusticl_opencl_bindings_rs = rust.bindgen(
'rusticl_opencl_bindings.h',
opencl_headers,
],
# required by 'CL_intel/cl_ext_private.h'
language : 'cpp',
output : 'rusticl_opencl_bindings.rs',
include_directories : [
inc_include,

View file

@ -12,6 +12,9 @@
#endif
#include "GL/mesa_glinterop.h"
/* We include custom vendor headers last */
#include "CL_intel/cl_ext_private.h"
#define DECL_CL_STRUCT(name) struct name { const cl_icd_dispatch *dispatch; }
DECL_CL_STRUCT(_cl_command_queue);
DECL_CL_STRUCT(_cl_context);