ID3D12GraphicsCommandList::SetComputeRootConstantBufferView method
Sets a CPU descriptor handle for the constant buffer in the compute root signature.
Syntax
void SetComputeRootConstantBufferView( [in] UINT RootParameterIndex, [in] D3D12_GPU_VIRTUAL_ADDRESS BufferLocation );
Parameters
- RootParameterIndex [in]
-
Type: UINT
The slot number for binding.
- BufferLocation [in]
-
Type: D3D12_GPU_VIRTUAL_ADDRESS
Specifies the D3D12_GPU_VIRTUAL_ADDRESS of the constant buffer.
Return value
This method does not return a value.
Examples
The D3D12nBodyGravity sample uses ID3D12GraphicsCommandList::SetComputeRootConstantBufferView as follows:
// Run the particle simulation using the compute shader. void D3D12nBodyGravity::Simulate(UINT threadIndex) { ID3D12GraphicsCommandList* pCommandList = m_computeCommandList[threadIndex].Get(); UINT srvIndex; UINT uavIndex; ID3D12Resource *pUavResource; if (m_srvIndex[threadIndex] == 0) { srvIndex = SrvParticlePosVelo0; uavIndex = UavParticlePosVelo1; pUavResource = m_particleBuffer1[threadIndex].Get(); } else { srvIndex = SrvParticlePosVelo1; uavIndex = UavParticlePosVelo0; pUavResource = m_particleBuffer0[threadIndex].Get(); } pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(pUavResource, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_UNORDERED_ACCESS)); pCommandList->SetPipelineState(m_computeState.Get()); pCommandList->SetComputeRootSignature(m_computeRootSignature.Get()); ID3D12DescriptorHeap* ppHeaps[] = { m_srvUavHeap.Get() }; pCommandList->SetDescriptorHeaps(_countof(ppHeaps), ppHeaps); CD3DX12_GPU_DESCRIPTOR_HANDLE srvHandle(m_srvUavHeap->GetGPUDescriptorHandleForHeapStart(), srvIndex + threadIndex, m_srvUavDescriptorSize); CD3DX12_GPU_DESCRIPTOR_HANDLE uavHandle(m_srvUavHeap->GetGPUDescriptorHandleForHeapStart(), uavIndex + threadIndex, m_srvUavDescriptorSize); pCommandList->SetComputeRootConstantBufferView(RootParameterCB, m_constantBufferCS->GetGPUVirtualAddress()); pCommandList->SetComputeRootDescriptorTable(RootParameterSRV, srvHandle); pCommandList->SetComputeRootDescriptorTable(RootParameterUAV, uavHandle); pCommandList->Dispatch(static_cast<int>(ceil(ParticleCount / 128.0f)), 1, 1); pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(pUavResource, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE)); }
See Example Code in the D3D12 Reference.
Requirements
|
Header |
|
|---|---|
|
Library |
|
|
DLL |
|
See also
Show: