Testing chained compute shader dispatches on Microsoft Basic Render Driver: Why might a UAV mutate between dispatches?

0

As per the title, I have a few different compute shaders (pipeline state objects) that I'm dispatching to (i.e. dispatch to shader0, shader0 does stuff to the uav, dispatch to shader1, shader1 does more stuff to the uav, etc.).

I'm testing this using both DX11 and DX12.

Running the shaders on my hardware gpu, everything runs fine and dandy as expected for both DX11 and DX12, but when I run it through the Microsoft Basic Render Driver on DX12, on dispatches the initial state of the UAV changes--

more specifically, all uint4 values in the uav are set to whatever is contained in the first position. For example, if after dispatching shader_(n), the first 12 uints stored in the uav are:

0x00000001 0x00000002 0x00000003 0x00000004 0x00000005 0x00000006 0x00000007 0x00000008 0x00000009 0x0000000a 0x0000000b 0x0000000c

then at the start of the dispatch to shader_(n+1), those first 12 will then be:

0x00000001 0x00000002 0x00000003 0x00000004 0x00000001 0x00000002 0x00000003 0x00000004 0x00000001 0x00000002 0x00000003 0x00000004

This does not occur when running through the DX11 code.

So to summarize:

DX11 Hardware GPU works as expected

DX12 Hardware GPU works as expected

DX11 Microsoft Basic Render driver works as expected


DX12 Microsoft Basic Render Driver mutates uav between dispatches


Has anyone else experienced similar behavior? Any thoughts on what I could try that has a decent chance of addressing this?

I can share some of my code if necessary; I haven't posted it just yet as it's a fairly large amount to go through and I'd rather narrow things down a bit first rather than dumping a ton here.

Edit: I'm adding what I suspect is the relevant code here:

    ...

    IndividualDispatch(
        this->prologueState.Get(),
        indexLog2);

    BetweenDispatches();

    IndividualDispatch(
        this->coreState.Get(),
        indexLog2);

    ...

Assuming that its not an issue with the initialization of everything (and that its not a bug with WARP), it seems most likely to me that there's an issue in either IndividualDispatch or BetweenDispatches--defined below.

void IndividualDispatch(
    _In_ ID3D12PipelineState* shader,
    const uint8_t indexLog2)
{
    CHR(this->directCommandList->Reset(
        this->directCommandAllocator.Get(),
        shader));

    this->directCommandList->SetComputeRootSignature(
        this->rootSignature.Get());

    this->directCommandList->SetComputeRootConstantBufferView(
        1,
        this->precomputeBuffer->GetGPUVirtualAddress());

    this->directCommandList->SetComputeRootConstantBufferView(
        0,
        this->bufferInfoBuffer->GetGPUVirtualAddress());

    this->directCommandList->SetComputeRootUnorderedAccessView(
        2,
        this->uavBuffer->GetGPUVirtualAddress());

    this->Dc12HasherImpl::Dispatch(
        this->directCommandList.Get(),
        indexLog2);
}

void BetweenDispatches()
{
    CHR(this->directCommandList->Close());

    DC12::ExecuteCommandList(
        this->directCommandQueue.Get(),
        this->directCommandList.Get());
}

static inline void ExecuteCommandList(
    _In_ ID3D12CommandQueue* pCommandQueue,
    _In_ ID3D12CommandList* pCommandList)
{
    pCommandQueue->ExecuteCommandLists(
        1,
        &pCommandList);
}

Is there something perhaps wrong with/missing from BetweenDispatches? Or something else glaringly wrong here?

c++
compute-shader
directx-12
asked on Stack Overflow Mar 10, 2019 by MNagy • edited Mar 11, 2019 by MNagy

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0