Metodo ID3D12GraphicsCommandList::D ispatch (d3d12.h)

Esegue un elenco di comandi da un gruppo di thread.

Sintassi

void Dispatch(
  [in] UINT ThreadGroupCountX,
  [in] UINT ThreadGroupCountY,
  [in] UINT ThreadGroupCountZ
);

Parametri

[in] ThreadGroupCountX

Tipo: UINT

Numero di gruppi inviati nella direzione x. ThreadGroupCountX deve essere minore o uguale a D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION (65535).

[in] ThreadGroupCountY

Tipo: UINT

Numero di gruppi inviati nella direzione y. ThreadGroupCountY deve essere minore o uguale a D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION (65535).

[in] ThreadGroupCountZ

Tipo: UINT

Numero di gruppi inviati nella direzione z. ThreadGroupCountZ deve essere minore o uguale a D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION (65535). Nel livello di funzionalità 10 il valore per ThreadGroupCountZ deve essere 1.

Valore restituito

nessuno

Osservazioni

Si chiama il metodo Dispatch per eseguire i comandi in uno shader di calcolo. Un shader di calcolo può essere eseguito in molti thread in parallelo, all'interno di un gruppo di thread. Indicizzare un thread specifico, all'interno di un gruppo di thread usando un vettore 3D specificato da (x,y,z).

Esempio

L'esempio D3D12nBodyGravity usa ID3D12GraphicsCommandList::D ispatch come indicato di seguito:

// 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));
}

Vedere Codice di esempio nel riferimento D3D12.

Requisiti

Requisito Valore
Piattaforma di destinazione Windows
Intestazione d3d12.h
Libreria D3d12.lib
DLL D3d12.dll

Vedi anche

ID3D12GraphicsCommandList