Microsoft DirectCompute is an application programming interface (API) that allows executing on GPGPU. It is supported on Microsoft's Windows Vista, Windows 7 and later versions. DirectCompute is part of the Microsoft DirectX collection of APIs, and was initially released with the Direct3D 11 API but runs on graphics processing units that support either Direct3D 10 or Direct3D 11.
This pipeline allows for workloads to be easily sent to the GPU without the need for restructuring all of a program's code.
A typical compute pipeline contains a read-only shader resource view as an input, constant buffer views for additional resource constants, and an unordered access view for an output. It is important to set the resource states of these resources in order to improve performance.
1, root_parameters,
0, nullptr
};
// Serialize the root signature
Microsoft::WRL::ComPtr
// Create the root signature
Microsoft::WRL::ComPtr
// Read the compute shader
Windows::WRL::ComPtr
// Create the compute pipeline state object (PSO)
struct PipelineStateStream {
// Setting the root signature and the compute shader to the PSO
pipeline_state_stream.root_signature = root_signature.Get();
pipeline_state_stream.compute_shader = CD3DX12_SHADER_BYTECODE{compute_shader.Get()};
D3D12_PIPELINE_STATE_STREAM_DESC pipeline_state_stream_desc{
// Create pipeline state
device->CreatePipelineState(
&root_signature_desc, D3D_ROOT_SIGNATURE_VERSION_1_1,
root_signature_blob.GetAddressOf(), error_blob.GetAddressOf()
);
0, root_signature_blob->GetBufferPointer(),
root_signature_blob->GetBufferSize(),
IID_PPV_ARGS(root_signature.GetAddressOf())
);
CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE root_signature;
CD3DX12_PIPELINE_STATE_STREAM_CS compute_shader;
} pipeline_state_stream;
sizeof(PipelineStateStream), &pipeline_state_stream
};
&pipeline_state_stream_desc,
IID_PPV_ARGS(pipeline_state_stream.GetAddressOf())
);
|
|