From d90fbdf4a5d8c47efd3d85fd03100259eae405b9 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Sat, 29 Nov 2025 00:44:22 +0100 Subject: [PATCH] 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: --- src/gallium/frontends/rusticl/api/memory.rs | 10 +++++++++- src/gallium/frontends/rusticl/core/program.rs | 2 ++ src/gallium/frontends/rusticl/meson.build | 2 ++ .../frontends/rusticl/rusticl_opencl_bindings.h | 3 +++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/gallium/frontends/rusticl/api/memory.rs b/src/gallium/frontends/rusticl/api/memory.rs index 3ec05a0dba8..ef949eef067 100644 --- a/src/gallium/frontends/rusticl/api/memory.rs +++ b/src/gallium/frontends/rusticl/api/memory.rs @@ -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(()) } diff --git a/src/gallium/frontends/rusticl/core/program.rs b/src/gallium/frontends/rusticl/core/program.rs index f884e0f0671..f9ef1e0614e 100644 --- a/src/gallium/frontends/rusticl/core/program.rs +++ b/src/gallium/frontends/rusticl/core/program.rs @@ -309,6 +309,8 @@ fn prepare_options(options: &str, dev: &Device) -> Vec { "-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) diff --git a/src/gallium/frontends/rusticl/meson.build b/src/gallium/frontends/rusticl/meson.build index 7db1151f695..d411712f2df 100644 --- a/src/gallium/frontends/rusticl/meson.build +++ b/src/gallium/frontends/rusticl/meson.build @@ -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, diff --git a/src/gallium/frontends/rusticl/rusticl_opencl_bindings.h b/src/gallium/frontends/rusticl/rusticl_opencl_bindings.h index 96de7b5882c..4f2e9ae432b 100644 --- a/src/gallium/frontends/rusticl/rusticl_opencl_bindings.h +++ b/src/gallium/frontends/rusticl/rusticl_opencl_bindings.h @@ -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);