I am implementing a H264 video decoder through Direct3D 12 APIs - while I am very new to Direct3D I do have experience with other graphics APIs and H264. I have been struggling to find decent examples of D3D12 video decoding but have got as far as seemingly successfully submitting my work to the decoder.
However, I am at a loss with how to query the decode status. From piecing together the documentation and some other code I found I think it's something like this - mapping the result into the status struct - but I get an invalid argument error. Could anyone point me in the right direction, and any good examples of D3D12 video decoding would be a great resource.
    // decode_commands is a ID3D12VideoDecodeCommandList
    // query_heap is a ID3D12QueryHeap
    // device is a ID3D12Device
    // Make query for decode stats.
    decode_commands->EndQuery(query_heap.Get(), D3D12_QUERY_TYPE::D3D12_QUERY_TYPE_VIDEO_DECODE_STATISTICS, 0);
    // Create buffer for query result.
    ComPtr<ID3D12Resource> query_result;
    D3D12_RESOURCE_DESC query_result_description = CD3DX12_RESOURCE_DESC::Buffer(sizeof(D3D12_QUERY_DATA_VIDEO_DECODE_STATISTICS));
    HRESULT create_query_result = device->CreateCommittedResource(
        &CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE::D3D12_HEAP_TYPE_DEFAULT),
        D3D12_HEAP_FLAGS::D3D12_HEAP_FLAG_NONE,
        &query_result_description,
        D3D12_RESOURCE_STATES::D3D12_RESOURCE_STATE_COPY_DEST,
        nullptr,
        IID_PPV_ARGS(&query_result));
    if (FAILED(create_query_result)) {
        log("Failed to create query result");
        return false;
    }
    // Resolve query.
    decode_commands->ResolveQueryData(query_heap.Get(), D3D12_QUERY_TYPE::D3D12_QUERY_TYPE_VIDEO_DECODE_STATISTICS, 0, 1, query_result.Get(), 0);
    // Get stats from query result.
    D3D12_RANGE range;
    range.Begin = 0;
    range.End = sizeof(D3D12_QUERY_DATA_VIDEO_DECODE_STATISTICS);
    D3D12_QUERY_DATA_VIDEO_DECODE_STATISTICS stats;
    HRESULT map = query_result->Map(0, &range, reinterpret_cast<void**>(&stats));
    if (FAILED(map)) {
        log("Failed to map query result");
        return false;
    }