Add explicit gfx1200/gfx1201 builds, runtime selection and per-target code objects. Guard staging, packaging and installation against mixed architectures; retain gfx1201 compatibility and strict K/M arithmetic. Adapt realdody's target configuration and MSVC binary16/BOOL portability fixes from ae530b0. Do not import its forced gfx12 layout on RDNA3. Add exhaustive binary16 and C++/PowerShell target contract regressions. Validation: 20 CTest gates on RX 9070 XT; four software-only gfx1200 gates; MSVC portability compile checks; exact 4K K async and M control outputs; isolated package install/restore and mixed-target rejection tests. No physical gfx1200 validation is claimed. Co-authored-by: realdody <[email protected]>
27 lines
1.7 KiB
PowerShell
27 lines
1.7 KiB
PowerShell
# Shared by the build, diagnostics, staging and game package scripts.
|
|
function Get-D4RGpuTarget([string]$Root, [string]$Requested) {
|
|
$configured=$null
|
|
$targetFile=Join-Path $Root 'gpu-target.json'
|
|
if (Test-Path -LiteralPath $targetFile) {
|
|
$configured=(Get-Content -LiteralPath $targetFile -Raw | ConvertFrom-Json).architecture
|
|
if ($configured -notin @('gfx1200','gfx1201')) { throw "Unsupported package GPU target: $configured" }
|
|
}
|
|
$target=if ($Requested) { $Requested } elseif ($configured) { $configured } else { 'gfx1201' }
|
|
if ($target -notin @('gfx1200','gfx1201')) { throw "Unsupported GPU target: $target" }
|
|
if (!$configured -and $target -ne 'gfx1201') { throw 'A gfx1200 build requires gpu-target.json; rebuild with -GpuArch gfx1200.' }
|
|
if ($configured -and $target -ne $configured) { throw "Requested $target differs from package target $configured" }
|
|
return $target
|
|
}
|
|
function Assert-D4RCodeObjectTarget([string]$Path, [string]$Target) {
|
|
if ($Target -notin @('gfx1200','gfx1201')) { throw "Unsupported GPU target: $Target" }
|
|
$reader=[IO.BinaryReader]::new([IO.File]::OpenRead($Path))
|
|
try { $header=$reader.ReadBytes(64) } finally { $reader.Dispose() }
|
|
if ($header.Length -ne 64 -or $header[0] -ne 127 -or $header[1] -ne 69 -or $header[2] -ne 76 -or $header[3] -ne 70 -or
|
|
$header[4] -ne 2 -or $header[5] -ne 1 -or $header[18] -ne 224 -or $header[19] -ne 0) {
|
|
throw "Invalid AMDGPU ELF64 code object: $Path"
|
|
}
|
|
# LLVM AMDGPU e_flags machine IDs; inspect, never patch or spoof them.
|
|
$expected=if ($Target -eq 'gfx1200') { 0x48 } else { 0x4e }
|
|
if ($header[48] -ne $expected) { throw "Code object does not target ${Target}: $Path (ELF machine=$($header[48]))" }
|
|
}
|