diff --git a/docs/features.txt b/docs/features.txt index 3a11728159c..f8b5d89351a 100644 --- a/docs/features.txt +++ b/docs/features.txt @@ -980,7 +980,7 @@ Rusticl extensions that are not part of any OpenCL version: cl_khr_pci_bus_info DONE (iris, nvc0, radeonsi, zink) cl_khr_priority_hints not started cl_khr_spirv_extended_debug_info not started - cl_khr_spirv_linkonce_odr not started + cl_khr_spirv_linkonce_odr DONE cl_khr_spirv_no_integer_wrap_decoration DONE cl_khr_srgb_image_writes not started cl_khr_subgroup_ballot not started diff --git a/docs/relnotes/new_features.txt b/docs/relnotes/new_features.txt index e69de29bb2d..83086befee9 100644 --- a/docs/relnotes/new_features.txt +++ b/docs/relnotes/new_features.txt @@ -0,0 +1 @@ +cl_khr_spirv_linkonce_odr in rusticl diff --git a/docs/rusticl.rst b/docs/rusticl.rst index 95fe40257c1..d8f4eb979f0 100644 --- a/docs/rusticl.rst +++ b/docs/rusticl.rst @@ -55,7 +55,7 @@ The minimum versions to build Rusticl are: - Clang: 15.0.0 Updating clang requires a rebuilt of mesa and rusticl if and only if the value of ``CLANG_RESOURCE_DIR`` changes. It is defined through ``clang/Config/config.h``. -- SPIRV-Tools: any version (recommended: v2022.3) +- SPIRV-Tools: any version (recommended: v2025.1) Afterwards you only need to add ``-Dgallium-rusticl=true -Dllvm=enabled -Drust_std=2021`` to your build options. diff --git a/src/compiler/clc/clc_helpers.cpp b/src/compiler/clc/clc_helpers.cpp index bec802b1317..fb2f2fdeb91 100644 --- a/src/compiler/clc/clc_helpers.cpp +++ b/src/compiler/clc/clc_helpers.cpp @@ -55,6 +55,7 @@ #include #include +#include #include #include #include @@ -1266,6 +1267,10 @@ private: const struct clc_logger *logger; }; +const char* clc_spirv_tools_version() { + return spvSoftwareVersionString(); +} + int clc_link_spirv_binaries(const struct clc_linker_args *args, const struct clc_logger *logger, diff --git a/src/compiler/clc/clc_helpers.h b/src/compiler/clc/clc_helpers.h index 1381b4c24a2..e0533795fc8 100644 --- a/src/compiler/clc/clc_helpers.h +++ b/src/compiler/clc/clc_helpers.h @@ -75,6 +75,9 @@ clc_link_spirv_binaries(const struct clc_linker_args *args, const struct clc_logger *logger, struct clc_binary *out_spirv); +const char * +clc_spirv_tools_version(); + bool clc_validate_spirv(const struct clc_binary *spirv, const struct clc_logger *logger, diff --git a/src/gallium/frontends/rusticl/core/device.rs b/src/gallium/frontends/rusticl/core/device.rs index 42ff8f013c4..a5a706d3473 100644 --- a/src/gallium/frontends/rusticl/core/device.rs +++ b/src/gallium/frontends/rusticl/core/device.rs @@ -644,6 +644,11 @@ impl Device { add_spirv(c"SPV_KHR_integer_dot_product"); add_spirv(c"SPV_KHR_no_integer_wrap_decoration"); + if self.linkonce_supported() { + add_ext(1, 0, 0, "cl_khr_spirv_linkonce_odr"); + add_spirv(c"SPV_KHR_linkonce_odr"); + } + if self.fp16_supported() { add_ext(1, 0, 0, "cl_khr_fp16"); } @@ -808,6 +813,32 @@ impl Device { }; } + pub fn linkonce_supported(&self) -> bool { + let version = unsafe { + match CStr::from_ptr(clc_spirv_tools_version()).to_str() { + Ok(v) => v, + Err(_) => return false, + } + }; + + // check format and compare to "v2025.1" + if !version.starts_with('v') { + return false; + } + + let version = &version[1..]; + if let Some((year_str, minor_version_str)) = version.split_once('.') { + let year = year_str.parse::(); + let minor_version = minor_version_str.parse::(); + + if year_str.len() == 4 && year.is_ok() && minor_version.is_ok() { + return version >= "2025.1"; + } + } + + false + } + pub fn fp16_supported(&self) -> bool { if !Platform::features().fp16 { return false;