Partial Graphics Programs - DirectX Developer Blog
Skip to main content
Search<br>Search
No results
Cancel
Nada Ouf
Overview
Following the GDC announcement of the partial graphics programs feature, we are pleased to announce that it is available today in the AgilitySDK 1.721-preview . Checkout the release blog for more details about the full release.
This preview serves as a first look to explore what might be possible to ship in a future retail Agility SDK. We encourage developers to try out the feature and provide feedback to https://discord.gg/directx which may influence the final design.
Downloads
AgilitySDK 1.721-preview: https://devblogs.microsoft.com/directx/directx12agility/
Drivers
See Appendix > Feature Support for the full table of each feature’s supported hardware.
IHV<br>Driver Link(s)
AMD<br>AMD Developer Preview Edition 26.10.07.02
Intel<br>Partial Programs support will be available in a future driver.
NVIDIA<br>Partial Programs support will be available in a future driver.
The WARP software device supports partial graphics programs: https://www.nuget.org/packages/Microsoft.Direct3D.WARP/1.65535.20-preview
Partial Graphics Programs
Some game titles have a huge number of unique PSO combinations that they need to be compiled before the game loads to avoid stutter. Precompiling these PSO heavy titles in advance for many different hardware configurations for distribution through advanced shader delivery or for the preloading screen would take a significant amount of time and create duplicate effort.
To address this, we are creating partial graphics programs. Partial graphics programs split the pipeline creation into two steps: create partial pre-rasterization and pixel shader programs containing common state used by different graphics pipelines, then link them together in a generic program with other state. As result, reducing the compilation time and deduplicating common state getting compiled. The full technical details of partial graphics programs can be found in the spec.
Sample walkthrough
Enabling partial graphics programs in an app
Before creating a D3D device, enable the D3D12StateObjectsExperiment experimental feature (this is a temporary step while the feature is in preview) as shown from the sample:
UUID experimentalFeatures[] = { D3D12StateObjectsExperiment };<br>HRESULT hr = D3D12EnableExperimentalFeatures(_countof(experimentalFeatures), experimentalFeatures,<br>nullptr, nullptr);<br>Once a D3D device has been created, double check that partial graphics programs are supported from the sample:
D3D12_FEATURE_DATA_PARTIAL_GRAPHICS_PROGRAMS partialGraphicsProgramTier = {};<br>ThrowIfFailed(m_device->CheckFeatureSupport(<br>D3D12_FEATURE_PARTIAL_GRAPHICS_PROGRAMS, &partialGraphicsProgramTier, sizeof(partialGraphicsProgramTier)));<br>if (partialGraphicsProgramTier.PartialGraphicsProgramsTier<br>Compiling Shaders
The sample app uses compiled shaders at runtime, though the shaders can be precompiled.
Partial graphics programs is a new way to define generic programs and, like generic programs, any shaders compiled with SM6.0+ can be used. The sample app uses a VS and PS compiled using SM6.0 as shown below.
// Compile VS + PS once.<br>ComPtr vertexShader;<br>ComPtr pixelShader;<br>ThrowIfFailed(CompileDxilLibraryFromFile(<br>GetAssetFullPath(L"shaders.hlsl").c_str(),<br>L"VSMain", L"vs_6_0", nullptr, 0, &vertexShader));<br>ThrowIfFailed(CompileDxilLibraryFromFile(<br>GetAssetFullPath(L"shaders.hlsl").c_str(),<br>L"PSMain", L"ps_6_0", nullptr, 0, &pixelShader));<br>Demonstrating partial graphics programs
The sample app demonstrates the usage of partial graphics programs by defining two core partial graphics programs in a collection that will be reused in 3 different generic programs with different blend specifications. The two partial graphics programs used are:
Prerasterization shader partial: This partial includes the vertex shader, primitive topology and input layout.
Pixel shader partial: This partial includes the pixel shader, render target formats and newly added pixel shader partial fields that specify late-linked blend subobject. The late-linked blend subobject flag allows the variation of the blend subobject when creating the full generic programs.
// Create collection state object containing partial graphics programs with common state<br>// Partial graphics programs in a collection are compiled when<br>// the collection is created, so the executable state object that<br>// references it only has to perform a cheap link step.<br>CD3DX12_STATE_OBJECT_DESC collectionDesc;<br>collectionDesc.SetStateObjectType(D3D12_STATE_OBJECT_TYPE_COLLECTION);
// Add subobjects needed in the partials<br>auto pConfig = collectionDesc.CreateSubobject();<br>pConfig->SetFlags(D3D12_STATE_OBJECT_FLAG_ALLOW_STATE_OBJECT_ADDITIONS);
auto pRootSig = collectionDesc.CreateSubobject();<br>pRootSig->SetRootSignature(m_rootSignature.Get());
auto pVS = collectionDesc.CreateSubobject();<br>CD3DX12_SHADER_BYTECODE...