The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

c/client: Run D3D12 swapchain initial barriers after all possible points of failure.

+27 -27
+27 -27
src/xrt/compositor/client/comp_d3d12_client.cpp
··· 525 525 /// @todo No idea if this is right, might depend on whether it's the compute or graphics compositor! 526 526 D3D12_RESOURCE_STATES compositorResourceState = D3D12_RESOURCE_STATE_COMMON; 527 527 528 - // app_images do not inherit the initial state of images, so 529 - // transition all app images from _COMMON to the correct state 530 - { 531 - D3D12_RESOURCE_BARRIER barrier{}; 532 - barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; 533 - barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_COMMON; 534 - barrier.Transition.StateAfter = appResourceState; 535 - barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; 536 - 537 - data->state.resize(image_count, barrier.Transition.StateAfter); 538 - 539 - std::vector<D3D12_RESOURCE_BARRIER> barriers; 540 - for (const auto &image : data->app_images) { 541 - barrier.Transition.pResource = image.get(); 542 - barriers.emplace_back(barrier); 543 - } 544 - wil::com_ptr<ID3D12GraphicsCommandList> commandList; 545 - THROW_IF_FAILED(c->device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, 546 - c->command_allocator.get(), nullptr, 547 - IID_PPV_ARGS(commandList.put()))); 548 - commandList->ResourceBarrier((UINT)barriers.size(), barriers.data()); 549 - commandList->Close(); 550 - std::array<ID3D12CommandList *, 1> commandLists{commandList.get()}; 551 - 552 - c->app_queue->ExecuteCommandLists((UINT)commandLists.size(), commandLists.data()); 553 - } 554 - 555 528 data->appResourceState = appResourceState; 556 529 data->compositorResourceState = compositorResourceState; 557 530 ··· 660 633 if (xret != XRT_SUCCESS) { 661 634 D3D_ERROR(c, "Error importing D3D swapchain into native compositor"); 662 635 return xret; 636 + } 637 + 638 + // app_images do not inherit the initial state of images, so 639 + // transition all app images from _COMMON to the correct state 640 + { 641 + D3D12_RESOURCE_BARRIER barrier{}; 642 + barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; 643 + barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_COMMON; 644 + barrier.Transition.StateAfter = appResourceState; 645 + barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; 646 + 647 + data->state.resize(image_count, barrier.Transition.StateAfter); 648 + 649 + std::vector<D3D12_RESOURCE_BARRIER> barriers; 650 + for (const auto &image : data->app_images) { 651 + barrier.Transition.pResource = image.get(); 652 + barriers.emplace_back(barrier); 653 + } 654 + wil::com_ptr<ID3D12GraphicsCommandList> commandList; 655 + THROW_IF_FAILED(c->device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, 656 + c->command_allocator.get(), nullptr, 657 + IID_PPV_ARGS(commandList.put()))); 658 + commandList->ResourceBarrier((UINT)barriers.size(), barriers.data()); 659 + commandList->Close(); 660 + std::array<ID3D12CommandList *, 1> commandLists{commandList.get()}; 661 + 662 + c->app_queue->ExecuteCommandLists((UINT)commandLists.size(), commandLists.data()); 663 663 } 664 664 665 665 auto release_image_fn = compositorNeedsCopy //