Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider allowing a computer or copy queue to be provided to ResourceUploadBatch #70

Closed
john-h-k opened this issue Apr 10, 2020 · 5 comments
Assignees

Comments

@john-h-k
Copy link

john-h-k commented Apr 10, 2020

Currently providing a ID3D12CommandQueue* to ResourceUploadBatch::End generates an error if the queue is not of type D3D12_COMMAND_LIST_TYPE_DIRECT;

    void Begin()
    {
        if (mInBeginEndBlock)
            throw std::exception("Can't Begin: already in a Begin-End block.");

        ThrowIfFailed(mDevice->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_GRAPHICS_PPV_ARGS(mCmdAlloc.ReleaseAndGetAddressOf())));

        SetDebugObjectName(mCmdAlloc.Get(), L"ResourceUploadBatch");

        ThrowIfFailed(mDevice->CreateCommandList(1, D3D12_COMMAND_LIST_TYPE_DIRECT, mCmdAlloc.Get(), nullptr, IID_GRAPHICS_PPV_ARGS(mList.ReleaseAndGetAddressOf())));

        SetDebugObjectName(mList.Get(), L"ResourceUploadBatch");

        mInBeginEndBlock = true;
    }

This can just be changed to

    void Begin(D3D12_COMMAND_LIST_TYPE commandType = D3D12_COMMAND_LIST_TYPE_DIRECT)
    {
        if (mInBeginEndBlock)
            throw std::exception("Can't Begin: already in a Begin-End block.");

        ThrowIfFailed(mDevice->CreateCommandAllocator(commandType, IID_GRAPHICS_PPV_ARGS(mCmdAlloc.ReleaseAndGetAddressOf())));

        SetDebugObjectName(mCmdAlloc.Get(), L"ResourceUploadBatch");

        ThrowIfFailed(mDevice->CreateCommandList(1, commandType, mCmdAlloc.Get(), nullptr, IID_GRAPHICS_PPV_ARGS(mList.ReleaseAndGetAddressOf())));

        SetDebugObjectName(mList.Get(), L"ResourceUploadBatch");

        mInBeginEndBlock = true;
    }

and this is now all fixed. Would be useful

@walbourn
Copy link
Member

That's a great suggestion. That said, I think only D3D12_COMMAND_LIST_TYPE_DIRECT, D3D12_COMMAND_LIST_TYPE_BUNDLE, or D3D12_COMMAND_LIST_TYPE_COPY would actually work. The class issues copy commands on the command-list, so D3D12_COMMAND_LIST_TYPE_COMPUTE wouldn't work.

@walbourn
Copy link
Member

The ResourceUploadBatch can also not use a D3D12_COMMAND_LIST_TYPE_COPY command-list when generating mipmaps.

@walbourn
Copy link
Member

And there are a few challenges with the implicit resource barrier.

@john-h-k
Copy link
Author

The ResourceUploadBatch can also not use a D3D12_COMMAND_LIST_TYPE_COPY command-list when generating mipmaps.

I guess the easiest way to go around this is check if mGenMipsResources isn't null in End, and if it isn't, then throw an exception?

@walbourn
Copy link
Member

Here's a PR for the library:

#71

Here's a PR for the test suite:

walbourn/directxtk12test#17

Please take a look at these instructions to try it out yourself as I can use some help in testing this on more systems.

@walbourn walbourn self-assigned this Apr 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants