mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 03:18:08 +02:00
rusticl/feat: LinkOnce ODR
Reviewed-by: Karol Herbst <None> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33133>
This commit is contained in:
parent
7bf4d6a4db
commit
457b159383
6 changed files with 42 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
cl_khr_spirv_linkonce_odr in rusticl
|
||||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@
|
|||
#include <clang/Frontend/Utils.h>
|
||||
#include <clang/Basic/TargetInfo.h>
|
||||
|
||||
#include <spirv-tools/libspirv.h>
|
||||
#include <spirv-tools/libspirv.hpp>
|
||||
#include <spirv-tools/linker.hpp>
|
||||
#include <spirv-tools/optimizer.hpp>
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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::<u32>();
|
||||
let minor_version = minor_version_str.parse::<u32>();
|
||||
|
||||
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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue