summaryrefslogtreecommitdiff
blob: 24ab0cf868e7aa42da1fe9a96015e17fc503ab7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit unpacker

MY_PV_HIGH=$(ver_cut 1)
MY_PV_MIDDLE=$(ver_cut 2)
MY_PV_LOW=$(ver_cut 3)
MY_PV_REV=$(ver_cut 4)

MY_PV="${MY_PV_HIGH}.${MY_PV_MIDDLE}"

INTERNAL_VER="6.0.3"

MY_PV_FULL="${MY_PV}-${MY_PV_REV}"

MY_PN="vulkan-amdgpu-pro"
MY_LINK="https://repo.radeon.com/amdgpu/${INTERNAL_VER}/ubuntu/pool/proprietary/v/${MY_PN}"

UBUNTU_VER="22.04"

DESCRIPTION="AMD's closed source vulkan driver, from Radeon Software for Linux"
HOMEPAGE="https://www.amd.com/en/support"
SRC_URI="
	abi_x86_64? ( ${MY_LINK}/${MY_PN}_${MY_PV_FULL}.${UBUNTU_VER}_amd64.deb -> ${P}-amd64.deb )
	abi_x86_32? ( ${MY_LINK}/${MY_PN}_${MY_PV_FULL}.${UBUNTU_VER}_i386.deb -> ${P}-i386.deb )
"
S="${WORKDIR}"

LICENSE="AMD-GPU-PRO-EULA"
SLOT="0"
KEYWORDS="-* amd64 ~x86"
IUSE="abi_x86_32 abi_x86_64 video_cards_amdgpu"

RESTRICT="bindist mirror"

REQUIRED_USE="video_cards_amdgpu"

BDEPEND="dev-util/patchelf"

QA_PREBUILT="
	usr/lib64/amdvlkpro64.so*
	usr/lib/amdvlkpro32.so*
"

src_unpack() {
	default

	if use abi_x86_64 ; then
		mkdir "${S}/${PN}-amd64" || die
		cd "${S}/${PN}-amd64" || die
		unpack_deb "${DISTDIR}/${P}-amd64.deb"
	fi

	if use abi_x86_32 ; then
		mkdir "${S}/${PN}-i386" || die
		cd "${S}/${PN}-i386" || die
		unpack_deb "${DISTDIR}/${P}-i386.deb"
	fi
}

src_prepare() {
	if use abi_x86_64 ; then
		cd "${S}/${PN}-amd64/opt/amdgpu-pro/lib/x86_64-linux-gnu/" || die

		# Add "pro" in the .so file's name
		mv amdvlk64.so amdvlkpro64.so || die

		# same with the SONAME
		patchelf --set-soname amdvlkpro64.so "${PWD}"/amdvlkpro64.so || die

		cd "${S}/${PN}-amd64/opt/amdgpu-pro/etc/vulkan/icd.d/" || die
		eapply "${FILESDIR}"/icd_amd64.patch
		mv amd_icd64.json amd_pro_icd64.json || die
	fi

	if use abi_x86_32 ; then
		cd "${S}/${PN}-i386/opt/amdgpu-pro/lib/i386-linux-gnu/" || die

		# Add "pro" in the .so file's name
		mv amdvlk32.so amdvlkpro32.so || die

		# same with the SONAME
		patchelf --set-soname amdvlkpro32.so "${PWD}"/amdvlkpro32.so || die

		cd "${S}/${PN}-i386/opt/amdgpu-pro/etc/vulkan/icd.d/" || die
		eapply "${FILESDIR}"/icd_x86.patch
		mv amd_icd32.json amd_pro_icd32.json || die
	fi

	default
}

src_install() {
	if use abi_x86_64 ; then
		# Vulkan driver
		insinto /usr/lib64
		doins "${S}"/"${PN}"-amd64/opt/amdgpu-pro/lib/x86_64-linux-gnu/amdvlkpro64.so

		# ICD loader
		insinto /usr/share/vulkan/icd.d
		doins "${S}"/"${PN}"-amd64/opt/amdgpu-pro/etc/vulkan/icd.d/amd_pro_icd64.json
	fi

	if use abi_x86_32 ; then
		# Vulkan driver
		insinto /usr/lib
		doins "${S}"/"${PN}"-i386/opt/amdgpu-pro/lib/i386-linux-gnu/amdvlkpro32.so

		# ICD loader
		insinto /usr/share/vulkan/icd.d
		doins "${S}"/"${PN}"-i386/opt/amdgpu-pro/etc/vulkan/icd.d/amd_pro_icd32.json
	fi

	# AMDGPU-PRO & RADV Vulkan prefix
	dobin "${FILESDIR}/vk_pro"
	dobin "${FILESDIR}/vk_radv"
}

pkg_postinst() {
	elog "To execute programs with the amdgpu-pro-vulkan driver:"
	elog "  - Use the `vk_pro` wrapper script: e.g. 'vk_pro vkcube'"
	elog "  - Define the following environment variable: "
	elog "    VK_DRIVER_FILES=/usr/share/vulkan/icd.d/amd_pro_icd64.json:/usr/share/vulkan/icd.d/amd_pro_icd32.json"
	elog
}