Merge branch 'yutji/directx-docker-build' into yutji/python-directx-coreflops

This commit is contained in:
yukirora 2023-06-14 12:32:37 +00:00
Родитель 613d524bcb b9cb309cf9
Коммит cdaa551053
7 изменённых файлов: 224 добавлений и 0 удалений

46
.github/workflows/build-win.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,46 @@
name: Build on Windows
on:
push:
branches:
- main
- release/*
pull_request:
branches:
- main
- release/*
jobs:
docker:
name: Docker build win2004
runs-on: [self-hosted, windows, x64, win2004]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
- name: Build Docker image
working-directory: .
shell: pwsh
run: |
docker build `
--file dockerfile/directx/win10.dockerfile `
--label org.opencontainers.image.source=${{ github.event.repository.html_url }} `
--label org.opencontainers.image.created=${{ github.event.repository.pushed_at }} `
--label org.opencontainers.image.revision=${{ github.sha }} `
--platform windows/amd64 `
--isolation=process `
--tag $env:TAG .
env:
TAG: superbench/main:win2004
- name: Push Docker image
if: ${{ github.event_name != 'pull_request' }}
shell: pwsh
run: |
docker login -u $env:USER -p $env:PASS
docker push $env:TAG
docker logout
env:
TAG: superbench/main:win2004
USER: ${{ secrets.DOCKERHUB_USERNAME }}
PASS: ${{ secrets.DOCKERHUB_TOKEN }}

Просмотреть файл

@ -14,6 +14,9 @@ cppformat:
cppbuild:
cd ./superbench/benchmarks/ && bash build.sh
directxcppbuild:
cd ./superbench/benchmarks/ && build.bat
thirdparty:
cd ./third_party/ && make all

Просмотреть файл

@ -0,0 +1,69 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""Enables graphics APIs in the Windows container."""
# Reference to
# https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Extras/Containers/Dockerfiles/windows/runtime/enable-graphics-apis.ps1
import os
import shutil
import glob
def copy_to_system32(source_directory, filenames, rename=None):
"""Copies the specified files from the source directory to the system32 directory."""
for filename in filenames:
source = os.path.join(source_directory, filename)
destination = os.path.join('C:\\Windows\\System32', filename)
if rename and filename in rename:
renamed = rename[filename]
destination = os.path.join('C:\\Windows\\System32', renamed)
try:
print(f'Copying {source} to {destination}')
shutil.copy2(source, destination)
except Exception as e:
print(f'Warning: failed to copy file {filename}. Reason: {str(e)}')
# Attempt to locate the NVIDIA Display Driver directory in the host system's driver store
nvidia_sentinel_file = glob.glob('C:\\Windows\\System32\\HostDriverStore\\FileRepository\\nv*.inf_amd64_*\\nvapi64.dll')
if nvidia_sentinel_file:
nvidia_directory = os.path.dirname(nvidia_sentinel_file[0])
print(f'Found NVIDIA Display Driver directory: {nvidia_directory}')
print('\nEnabling NVIDIA NVAPI support:')
copy_to_system32(nvidia_directory, ['nvapi64.dll'])
print('\nEnabling NVIDIA NVENC support:')
copy_to_system32(nvidia_directory, ['nvEncodeAPI64.dll', 'nvEncMFTH264x.dll', 'nvEncMFThevcx.dll'])
print('\nEnabling NVIDIA CUVID/NVDEC support:')
copy_to_system32(
nvidia_directory, ['nvcuvid64.dll', 'nvDecMFTMjpeg.dll', 'nvDecMFTMjpegx.dll'],
{'nvcuvid64.dll': 'nvcuvid.dll'}
)
print('\nEnabling NVIDIA CUDA support:')
copy_to_system32(
nvidia_directory, ['nvcuda64.dll', 'nvcuda_loader64.dll', 'nvptxJitCompiler64.dll'],
{'nvcuda_loader64.dll': 'nvcuda.dll'}
)
print('\n')
# Attempt to locate the AMD Display Driver directory in the host system's driver store
amd_sentinel_file = glob.glob('C:\\Windows\\System32\\HostDriverStore\\FileRepository\\u*.inf_amd64_*\\*\\aticfx64.dll')
if amd_sentinel_file:
amd_directory = os.path.dirname(amd_sentinel_file[0])
print(f'Found AMD Display Driver directory: {amd_directory}')
print('\nCopying AMD DirectX driver files:')
copy_to_system32(amd_directory, ['aticfx64.dll', 'atidxx64.dll'])
print('\nEnabling AMD Display Library (ADL) support:')
copy_to_system32(amd_directory, ['atiadlxx.dll', 'atiadlxy.dll'])
print('\nEnabling AMD Advanced Media Framework (AMF) support:')
copy_to_system32(amd_directory, ['amfrt64.dll', 'amfrtdrv64.dll', 'amdihk64.dll'])
print('\n')

Просмотреть файл

@ -0,0 +1,9 @@
REM Copyright (c) Microsoft Corporation - All rights reserved
REM Licensed under the MIT License
curl -s -L https://aka.ms/vs/17/release/vs_BuildTools.exe -o "vs_BuildTools.exe"
start /b /wait vs_BuildTools.exe --config %SB_HOME%\dockerfile\directx\mini_vsconfig.json --wait --quiet --norestart --nocache
if %errorlevel% neq 0 (
exit /b %errorlevel%
)
del "vs_BuildTools.exe"

Просмотреть файл

@ -0,0 +1,14 @@
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Component.Windows10SDK.19041",
"Microsoft.VisualStudio.Workload.VCTools",
"Microsoft.Component.MSBuild",
"Microsoft.VisualStudio.Component.CoreBuildTools",
"Microsoft.VisualStudio.Workload.MSBuildTools",
"Microsoft.VisualStudio.Component.VC.CoreBuildTools",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.35.17.5.ATL.Spectre",
"Microsoft.VisualStudio.Component.VC.14.35.17.5.MFC.Spectre"
]
}

Просмотреть файл

@ -0,0 +1,65 @@
FROM mcr.microsoft.com/windows:2004
# Install Python and additional packages
# Download Python
ADD https://www.python.org/ftp/python/3.9.7/python-3.9.7-amd64.exe python-installer.exe
# Install Python
RUN python-installer.exe /quiet InstallAllUsers=1 PrependPath=1 && DEL python-installer.exe
# Verify Python Was Successfully Installed
RUN python --version && \
python -m ensurepip --upgrade
# Install choco and install some necessary packages
RUN powershell -Command "Set-ExecutionPolicy Bypass -Scope Process -Force; \
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; \
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"
RUN choco install -y vcredist-all vim git make
# Retrieve the DirectX runtime files required by the Unreal Engine, since even the full Windows base image does not include them
RUN mkdir C:\GatheredDlls
RUN curl -s -L "https://download.microsoft.com/download/8/4/A/84A35BF1-DAFE-4AE8-82AF-AD2AE20B6B14/directx_Jun2010_redist.exe" --output %TEMP%\directx_redist.exe && \
start /wait %TEMP%\directx_redist.exe /Q /T:%TEMP%\DirectX && \
expand %TEMP%\DirectX\APR2007_xinput_x64.cab -F:xinput1_3.dll C:\GatheredDlls\ && \
expand %TEMP%\DirectX\Feb2010_X3DAudio_x64.cab -F:X3DAudio1_7.dll C:\GatheredDlls\ && \
expand %TEMP%\DirectX\Jun2010_D3DCompiler_43_x64.cab -F:D3DCompiler_43.dll C:\GatheredDlls\ && \
expand %TEMP%\DirectX\Jun2010_XAudio_x64.cab -F:XAudio2_7.dll C:\GatheredDlls\ && \
expand %TEMP%\DirectX\Jun2010_XAudio_x64.cab -F:XAPOFX1_5.dll C:\GatheredDlls\ && \
break
# Retrieve the DirectX shader compiler files needed for DirectX Raytracing (DXR)
RUN curl -s -L "https://github.com/microsoft/DirectXShaderCompiler/releases/download/v1.6.2104/dxc_2021_04-20.zip" --output %TEMP%\dxc.zip && \
powershell -Command "Expand-Archive -Path \"$env:TEMP\dxc.zip\" -DestinationPath $env:TEMP" && \
xcopy /y %TEMP%\bin\x64\dxcompiler.dll C:\GatheredDlls\ && \
xcopy /y %TEMP%\bin\x64\dxil.dll C:\GatheredDlls\ && \
break
# Copy the required DLLs to System32 dir
RUN xcopy C:\GatheredDlls\* C:\windows\System32\ /i
ENV SB_HOME="C:/opt/superbench" \
SB_MICRO_PATH="C:/opt/superbench" \
WindowsSDKDir="\\Program Files (x86)\\Windows Kits\\10\\"
RUN setx INCLUDE "%include%;%WindowsSDKDir%\\Include" /M && \
setx LIB "%lib%;%WindowsSDKDir%\\Lib" /M && \
setx PATH "%path%;%SB_MICRO_PATH%\\bin" /M
WORKDIR ${SB_HOME}
COPY ./ ${SB_HOME}
# Download vs_BuildTools.exe if not already present
RUN mkdir "%SB_MICRO_PATH%/bin"
RUN curl -s -L https://aka.ms/vs/17/release/vs_BuildTools.exe -o "%SB_MICRO_PATH%/bin/vs_BuildTools.exe" && \
curl -s -L https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -o "%SB_MICRO_PATH%/bin/nuget.exe"
# Run the setup script to install the visual studio components
RUN "%SB_HOME%\\dockerfile\\directx\\install-components.bat"
# Install Superbench
RUN python -m pip install setuptools==65.0.0 && \
python -m pip install --no-cache-dir .[amdworker] && \
make directxcppbuild
# Run the entrypoint script for enabling vendor-specific graphics APIs
RUN powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force"
ENTRYPOINT [ "python", "dockerfile/directx/enable-graphics-apis.py" ]

Просмотреть файл

@ -0,0 +1,18 @@
@echo off
REM Copyright (c) Microsoft Corporation - All rights reserved
REM Licensed under the MIT License
SETLOCAL EnableDelayedExpansion
for /r %%F in (*.sln) do (
echo Found .sln file: %%~dpF%%~nxF
SET "SLN_PATH=%%~dpF%%~nxF"
SET "MSBUILD=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe"
REM Download dependencies
"!MSBUILD!" "!SLN_PATH!" -t:restore -p:RestorePackagesConfig=true
REM Build project
"!MSBUILD!" "!SLN_PATH!" /p:Configuration=Release /p:AdditionalLibraryDirectories="%WindowsSDKDir%\Lib" /p:AdditionalIncludeDirectories="%WindowsSDKDir%\Include" /p:OutDir="%SB_MICRO_PATH%\bin"
)
endlocal