ID3D12Device::SerializeComputePipelineStateX Method

Serializes a compute pipeline state object as a means of allowing efficient loading at run-time. This method is called during offline content creation, not at game run-time.

Syntax

public:
HRESULT D3DAPI SerializeComputePipelineStateX(
         ID3D12PipelineState *pPipelineState,
         UINT Flags,
         D3D12XBOX_SERIALIZE_COMPUTE_PIPELINE_STATE *pSerializeState
)  

Parameters

pPipelineState
Type: ID3D12PipelineState *

[in] A pointer to the compute pipeline state to serialize.

Flags
Type: UINT 

[in] Flags to control this operation as a bitwise-OR’d combination of D3D12XBOX_SERIALIZE_FLAGS enumeration constants. Currently must be D3D12XBOX_SERIALIZE_FLAGS_NONE.

pSerializeState
Type: D3D12XBOX_SERIALIZE_COMPUTE_PIPELINE_STATE *

[out] The resulting serialized state.

Return value

Type: HRESULT D3DAPI 

One of the Direct3D 12 return codes.

Remarks

This method serializes a Pipeline State object as a means of allowing efficient loading at run-time. It is intended to be called as part of an offline content creation process and is never intended to be called at run-time of a game. Typical usage will be for a PC-based tool that invokes the PC-based UMD12_PC.DLL implementation of the Xbox One Direct3D 12.x API, driver, and shader compiler. This method can also be called on Xbox One devkits when using the flags D3D12XBOX_PROCESS_DEBUG_FLAG_INSTRUMENTED or D3D12_PROCESS_DEBUG_FLAG_DEBUG_LAYER_ENABLED. (These flags are enumeration constants in the D3D12XBOX_PROCESS_DEBUG_FLAGS enumeration.)

Calling this method will serialize a Pipeline State object into its components pieces in a form that can be very efficiently loaded at run-time by ID3D12Device::DeserializeComputePipelineStateX. Callers are expected to de-duplicate the resulting components across their collection of Pipeline State objects so as to avoid wasted space on disk and in memory. For example, multiple Pipeline State objects are likely to have exactly the same set of GPU instructions for a shader when only shader limits are different between the objects. It is up to the developer to do a hash or memory compare across such invocations and identify component pieces that can be shared. Developers manage the placement and lifetime of all serialized Pipeline State object components at run-time and specify the locations of the serialized Pipeline State object components in the call to DeserializeComputePipelineStateX, making it easy to facilitate such sharing.

For a typical game, most Pipeline State objects are created offline using this SerializeComputePipelineStateX/DeserializeComputePipelineStateX mechanism.

De-seralized shaders can be used in conjunction with ID3D12Device::CreateDerivedComputePipelineStateX to allow for efficient creation of Pipeline State object variations at run-time. This means that it is not necessary to create all possible state permutations of Pipeline State objects using SerializeComputePipelineStateX.

SerializeComputePipelineStateX returns ID3DBlob structures for each of the resulting component pieces. The caller should call ID3DBlob::GetBufferPointer and ID3DBlob::GetBufferSize to query the resulting component buffers, and call Release when done copying the results in order to free the memory. The blob pointers may be null for shaders that aren’t active. Some shaders may have a pGpuInstructions blob but not a corresponding pMetaData blob. (pGpuInstructions and pMetaData are members of the D3D12XBOX_SERIALIZE_SHADER structure). All component pieces must be persisted and supplied back to ID3D12Device::DeserializeComputePipelineStateX.

D3D12.x uses a CRC to ensure that all component pieces supplied to DeserializeComputePipelineStateX exactly match those generated by SerializeComputePipelineStateX.

Requirements

Header: Declared in d3d12_x.h.

Library: Use d3d12_x.lib.