Enable NVK driver

Resolves: https://issues.redhat.com/browse/RHEL-108427
This commit is contained in:
José Expósito 2025-08-20 09:03:42 +02:00
parent 7e229e5888
commit a95d4f28d4
3 changed files with 95 additions and 17 deletions

5
.gitignore vendored
View File

@ -8,3 +8,8 @@ results_mesa/
mesa-*/
/libclc-*.tar.xz
/spirv-llvm-translator-*.tar.gz
/paste-1.0.15.tar.gz
/proc-macro2-1.0.97.tar.gz
/quote-1.0.40.tar.gz
/syn-2.0.104.tar.gz
/unicode-ident-1.0.18.tar.gz

102
mesa.spec
View File

@ -9,11 +9,11 @@
%global with_r300 1
%global with_r600 1
%global with_nine 1
%if 0%{?with_vulkan_hw}
%global with_nvk %{with_vulkan_hw}
%endif
%global with_opencl 1
%endif
%if !0%{?rhel} || 0%{?rhel} >= 10
%global with_nvk %{with_vulkan_hw}
%endif
%global base_vulkan %{?with_vulkan_hw:,amd}%{!?with_vulkan_hw:%{nil}}
%endif
@ -64,6 +64,10 @@
%global vulkan_drivers swrast%{?base_vulkan}%{?intel_platform_vulkan}%{?extra_platform_vulkan}%{?with_nvk:,nouveau}
%if 0%{?with_nvk} && 0%{?rhel}
%global vendor_nvk_crates 1
%endif
Name: mesa
Summary: Mesa graphics libraries
%global ver 25.0.7
@ -99,6 +103,21 @@ BuildRequires: spirv-headers-devel
BuildRequires: spirv-tools-devel
BuildRequires: zlib-devel
# In CentOS/RHEL, Rust crates required to build NVK are vendored.
# The minimum target versions are obtained from the .wrap files
# https://gitlab.freedesktop.org/mesa/mesa/-/tree/main/subprojects
# but we generally want the latest compatible versions
%global rust_paste_ver 1.0.15
%global rust_proc_macro2_ver 1.0.97
%global rust_quote_ver 1.0.40
%global rust_syn_ver 2.0.104
%global rust_unicode_ident_ver 1.0.18
Source10: https://crates.io/api/v1/crates/paste/%{rust_paste_ver}/download#/paste-%{rust_paste_ver}.tar.gz
Source11: https://crates.io/api/v1/crates/proc-macro2/%{rust_proc_macro2_ver}/download#/proc-macro2-%{rust_proc_macro2_ver}.tar.gz
Source12: https://crates.io/api/v1/crates/quote/%{rust_quote_ver}/download#/quote-%{rust_quote_ver}.tar.gz
Source13: https://crates.io/api/v1/crates/syn/%{rust_syn_ver}/download#/syn-%{rust_syn_ver}.tar.gz
Source14: https://crates.io/api/v1/crates/unicode-ident/%{rust_unicode_ident_ver}/download#/unicode-ident-%{rust_unicode_ident_ver}.tar.gz
Patch10: gnome-shell-glthread-disable.patch
# Backport of https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33805
@ -187,15 +206,14 @@ BuildRequires: pkgconfig(SPIRV-Tools)
%endif
%if 0%{?with_opencl} || 0%{?with_nvk}
BuildRequires: bindgen
BuildRequires: rust-packaging
%if 0%{?rhel}
BuildRequires: rust-toolset
%else
BuildRequires: cargo-rpm-macros
%endif
%endif
%if 0%{?with_nvk}
BuildRequires: cbindgen
BuildRequires: (crate(paste) >= 1.0.14 with crate(paste) < 2)
BuildRequires: (crate(proc-macro2) >= 1.0.56 with crate(proc-macro2) < 2)
BuildRequires: (crate(quote) >= 1.0.25 with crate(quote) < 2)
BuildRequires: (crate(syn/clone-impls) >= 2.0.15 with crate(syn/clone-impls) < 3)
BuildRequires: (crate(unicode-ident) >= 1.0.6 with crate(unicode-ident) < 2)
%endif
%if %{with valgrind}
BuildRequires: pkgconfig(valgrind)
@ -411,6 +429,45 @@ tar -xvf %{SOURCE3}
# Extract spirv-llvm-translator
tar -xvf %{SOURCE4}
# Extract Rust crates meson cache directory
%if 0%{?vendor_nvk_crates}
mkdir subprojects/packagecache/
tar -xvf %{SOURCE10} -C subprojects/packagecache/
tar -xvf %{SOURCE11} -C subprojects/packagecache/
tar -xvf %{SOURCE12} -C subprojects/packagecache/
tar -xvf %{SOURCE13} -C subprojects/packagecache/
tar -xvf %{SOURCE14} -C subprojects/packagecache/
for d in subprojects/packagecache/*-*; do
echo '{"files":{}}' > $d/.cargo-checksum.json
done
%endif
%if 0%{?with_nvk}
cat > Cargo.toml <<_EOF
[package]
name = "mesa"
version = "%{version}"
edition = "2021"
[lib]
path = "src/nouveau/nil/lib.rs"
# only direct dependencies need to be listed here
[dependencies]
paste = "$(grep ^directory subprojects/paste.wrap | sed 's|.*-||')"
syn = { version = "$(grep ^directory subprojects/syn.wrap | sed 's|.*-||')", features = ["clone-impls"] }
_EOF
%if 0%{?vendor_nvk_crates}
%cargo_prep -v subprojects/packagecache
%else
%cargo_prep
%generate_buildrequires
%cargo_generate_buildrequires
%endif
%endif
%build
# Build spirv-llvm-translator
cd SPIRV-LLVM-Translator-%{spirv_llvm_trans_commit}
@ -453,16 +510,19 @@ sed -e "s!libexecdir=!libexecdir=\/%{buildroot}!" -i %{buildroot}%{_libdir}/pkgc
export RUSTFLAGS="%build_rustflags"
%if 0%{?with_nvk}
export MESON_PACKAGE_CACHE_DIR="%{cargo_registry}/"
# So... Meson can't actually find them without tweaks
%define inst_crate_nameversion() %(basename %{cargo_registry}/%{1}-*)
%define rewrite_wrap_file() sed -e "/source.*/d" -e "s/%{1}-.*/%{inst_crate_nameversion %{1}}/" -i subprojects/%{1}.wrap
%if !0%{?vendor_nvk_crates}
export MESON_PACKAGE_CACHE_DIR="%{cargo_registry}/"
%endif
rewrite_wrap_file() {
sed -e "/source.*/d" -e "s/${1}-.*/$(basename ${MESON_PACKAGE_CACHE_DIR:-subprojects/packagecache}/${1}-*)/" -i subprojects/${1}.wrap
}
%rewrite_wrap_file proc-macro2
%rewrite_wrap_file quote
%rewrite_wrap_file syn
%rewrite_wrap_file unicode-ident
%rewrite_wrap_file paste
rewrite_wrap_file proc-macro2
rewrite_wrap_file quote
rewrite_wrap_file syn
rewrite_wrap_file unicode-ident
rewrite_wrap_file paste
%endif
# We've gotten a report that enabling LTO for mesa breaks some games. See
@ -520,6 +580,14 @@ export MESON_PACKAGE_CACHE_DIR="%{cargo_registry}/"
%{nil}
%meson_build
%if 0%{?with_nvk}
%cargo_license_summary
%{cargo_license} > LICENSE.dependencies
%if 0%{?vendor_nvk_crates}
%cargo_vendor_manifest
%endif
%endif
%install
%meson_install

View File

@ -1,3 +1,8 @@
SHA512 (libclc-20.1.3.src.tar.xz) = ab6fb0dd0250ab9087b84cf6ec253473cdbcf473e24b626509f1aca1893718608ba31902fa6925ec99f64b1b06d60d49fecb2138c72c8aec433c124c57efad57
SHA512 (mesa-25.0.7.tar.xz) = 825bbd8bc5507de147488519786c0200afacf97dae621c80ead24b2c5dd55c5a442757ac8452698ae611e9344025465080795cf8f2dc4eb7ce07b5cc521b2b5c
SHA512 (paste-1.0.15.tar.gz) = 5026d3ec7141ec4e2517a0b1283912d0801e9356f77b703d954b379439b8d85e3886d42fb28f7835edaeeac465582da14233564fb010c71425a59c9e1cbd46b4
SHA512 (proc-macro2-1.0.97.tar.gz) = 6dbb60c29d252f276b1b0fadb707ff0e36fbb5f2a460630b461c9e3fa9d37aa7782cadf773039ec0d5653033b54c9f7cfcfaf3b9f802e882977e0d221e016927
SHA512 (quote-1.0.40.tar.gz) = 45a76e22a2b0bec47e4ba73c3b73cc41d821dfcce9876134c5d8eed514da214aee4ce7612e372c8709f888c0d8b9b7e5442f27adb7a59f3571f0339ed7e2ac99
SHA512 (spirv-llvm-translator-834db1a.tar.gz) = 4fb522087728a76204d1db9fb782afbe9475e57135d56d4b694d111aa1092febebd829fe42007d2e15e2c9bd1222bab6c48e89181fc5bdae7f3628fdf7ad74ac
SHA512 (syn-2.0.104.tar.gz) = da532fa362266161b5604c821c913f8f990eb32c18e18c0a360b7147b9f71ae008e208f377cb203e85818bd5db926951122a971fa97563a10678f0ba4671e64f
SHA512 (unicode-ident-1.0.18.tar.gz) = d11f89fb696f9e2953c96a40b5478832651b268c83b9c7a700b07e768e795d6e8dc346597d1226df21219d36866768d1f640bd8edb68db8bd3d5d437b2bfd324