Skip to content

Commit

Permalink
nvofapi-d3d12: Use COM template
Browse files Browse the repository at this point in the history
  • Loading branch information
jp7677 committed Nov 9, 2024
1 parent e2a2ac9 commit 6e5e732
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 33 deletions.
6 changes: 3 additions & 3 deletions src/nvofapi/nvofapi_d3d12_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,18 @@ namespace dxvk {
// Use vkd3d-proton's interop functionality to grab a VkCommandBuffer
// that we record our commands into. Work submission and synchronization
// happens using D3D12.
m_cmdLists[m_cmdListIndex]->Reset(m_cmdAllocator, nullptr);
m_cmdLists[m_cmdListIndex]->Reset(m_cmdAllocator.ptr(), nullptr);

for (uint32_t i = 0; i < inParams->numFencePoints; i++) {
m_commandQueue->Wait(inParams->fencePoint[i].fence, inParams->fencePoint[i].value);
}

VkCommandBuffer vkCmdBuf;
m_device->BeginVkCommandBufferInterop(m_cmdLists[m_cmdListIndex], &vkCmdBuf);
m_device->BeginVkCommandBufferInterop(m_cmdLists[m_cmdListIndex].ptr(), &vkCmdBuf);

this->RecordCmdBuf(&vkInputParams, &vkOutputParams, vkCmdBuf);

m_device->EndVkCommandBufferInterop(m_cmdLists[m_cmdListIndex]);
m_device->EndVkCommandBufferInterop(m_cmdLists[m_cmdListIndex].ptr());
m_cmdLists[m_cmdListIndex]->Close();

m_commandQueue->ExecuteCommandLists(1, reinterpret_cast<ID3D12CommandList**>(&m_cmdLists[m_cmdListIndex]));
Expand Down
39 changes: 9 additions & 30 deletions src/nvofapi/nvofapi_d3d12_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,48 +25,27 @@

#include "../nvofapi_private.h"
#include "nvofapi_instance.h"
#include "../util/com_pointer.h"

namespace dxvk {
class NvOFInstanceD3D12 : public NvOFInstance {

public:
NvOFInstanceD3D12(ID3D12Device* pD3D12Device);

virtual ~NvOFInstanceD3D12() {
for (auto& cmdList : m_cmdLists) {
if (cmdList)
cmdList->Release();
}
if (m_cmdAllocator)
m_cmdAllocator->Release();

if (m_commandQueue)
m_commandQueue->Release();

if (m_deviceExt)
m_deviceExt->Release();

if (m_d3ddevice)
m_d3ddevice->Release();

if (m_device)
m_device->Release();
}

void Execute(const NV_OF_EXECUTE_INPUT_PARAMS_D3D12* inParams, NV_OF_EXECUTE_OUTPUT_PARAMS_D3D12* outParams);
~NvOFInstanceD3D12() override = default;

bool Initialize();

void Execute(const NV_OF_EXECUTE_INPUT_PARAMS_D3D12* inParams, NV_OF_EXECUTE_OUTPUT_PARAMS_D3D12* outParams);
void RegisterBuffer(const NV_OF_REGISTER_RESOURCE_PARAMS_D3D12* registerParams);

private:
ID3D12DXVKInteropDevice1* m_device{};
ID3D12DeviceExt* m_deviceExt{};
ID3D12Device4* m_d3ddevice{};
ID3D12CommandQueue* m_commandQueue{};
std::array<ID3D12GraphicsCommandList*, CMDS_IN_FLIGHT> m_cmdLists{};
Com<ID3D12DXVKInteropDevice1> m_device{};
Com<ID3D12DeviceExt> m_deviceExt{};
Com<ID3D12Device4> m_d3ddevice{};
Com<ID3D12CommandQueue> m_commandQueue{};
std::array<Com<ID3D12GraphicsCommandList>, CMDS_IN_FLIGHT> m_cmdLists{};
uint32_t m_cmdListIndex{0};
ID3D12CommandAllocator* m_cmdAllocator{};
Com<ID3D12CommandAllocator> m_cmdAllocator{};

uint32_t m_vkQueueFamilyIndex{0};
};
Expand Down

0 comments on commit 6e5e732

Please sign in to comment.