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

Use COM template #224

Merged
merged 3 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ nvapi_src = files([
'util/util_string.cpp',
'util/util_env.cpp',
'util/util_log.cpp',
'nvapi/resource_factory.cpp',
'nvapi/lfx.cpp',
'nvapi/nvapi_d3d_instance.cpp',
'nvapi/nvapi_d3d_low_latency_device.cpp',
Expand All @@ -12,7 +13,6 @@ nvapi_src = files([
'nvapi/nvapi_output.cpp',
'nvapi/vulkan.cpp',
'nvapi/nvml.cpp',
'resource_factory.cpp',
'nvapi_globals.cpp',
'nvapi.cpp',
'nvapi_d3d.cpp',
Expand All @@ -39,10 +39,10 @@ nvofapi_src = files([
'nvofapi/nvofapi_image.cpp',
'nvofapi/nvofapi_instance.cpp',
'nvofapi/nvofapi_d3d12_instance.cpp',
'nvofapi/nvofapi_vulkan_instance.cpp',
'nvofapi/nvofapi_vk_instance.cpp',
'nvofapi.cpp',
'nvofapi_d3d12.cpp',
'nvofapi_vulkan.cpp',
'nvofapi_vk.cpp',
])

# Only build 64-bit versions of nvofapi
Expand Down
2 changes: 1 addition & 1 deletion src/nvapi/nvapi_adapter_registry.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "../nvapi_private.h"
#include "../resource_factory.h"
#include "resource_factory.h"
#include "nvapi_adapter.h"
#include "nvapi_output.h"
#include "vulkan.h"
Expand Down
2 changes: 1 addition & 1 deletion src/nvapi/nvapi_d3d_instance.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "../nvapi_private.h"
#include "../resource_factory.h"
#include "resource_factory.h"

namespace dxvk {
class NvapiD3dInstance {
Expand Down
6 changes: 3 additions & 3 deletions src/resource_factory.cpp → src/nvapi/resource_factory.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "resource_factory.h"
#include "interfaces/dxvk_interfaces.h"
#include "util/util_string.h"
#include "util/util_log.h"
#include "../interfaces/dxvk_interfaces.h"
#include "../util/util_string.h"
#include "../util/util_log.h"

namespace dxvk {
ResourceFactory::ResourceFactory() = default;
Expand Down
10 changes: 5 additions & 5 deletions src/resource_factory.h → src/nvapi/resource_factory.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once

#include "nvapi_private.h"
#include "util/com_pointer.h"
#include "nvapi/vulkan.h"
#include "nvapi/nvml.h"
#include "nvapi/lfx.h"
#include "../nvapi_private.h"
#include "../util/com_pointer.h"
#include "vulkan.h"
#include "nvml.h"
#include "lfx.h"

namespace dxvk {
class ResourceFactory {
Expand Down
2 changes: 1 addition & 1 deletion src/nvapi_globals.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "nvapi_private.h"
#include "resource_factory.h"
#include "nvapi/resource_factory.h"
#include "nvapi/nvapi_adapter_registry.h"
#include "nvapi/nvapi_d3d_instance.h"

Expand Down
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<ID3D12Device4> m_d3ddevice{};
Com<ID3D12DeviceExt> m_deviceExt{};
Com<ID3D12CommandQueue> m_commandQueue{};
Com<ID3D12CommandAllocator> m_cmdAllocator{};
std::array<Com<ID3D12GraphicsCommandList>, CMDS_IN_FLIGHT> m_cmdLists{};
uint32_t m_cmdListIndex{0};
ID3D12CommandAllocator* m_cmdAllocator{};

uint32_t m_vkQueueFamilyIndex{0};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*/

#include "nvofapi_vulkan_instance.h"
#include "nvofapi_vk_instance.h"
#include "../util/util_log.h"

namespace dxvk {
Expand Down
2 changes: 1 addition & 1 deletion src/nvofapi_vulkan.cpp → src/nvofapi_vk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*/

#include "nvofapi/nvofapi_vulkan_instance.h"
#include "nvofapi/nvofapi_vk_instance.h"
#include "nvofapi/nvofapi_image.h"
#include "nvofapi_entrypoints.h"
#include "util/util_env.h"
Expand Down
2 changes: 1 addition & 1 deletion tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ nvapi_src = files([
'../src/util/util_string.cpp',
'../src/util/util_env.cpp',
'../src/util/util_log.cpp',
'../src/nvapi/resource_factory.cpp',
'../src/nvapi/vulkan.cpp',
'../src/nvapi/nvml.cpp',
'../src/nvapi/lfx.cpp',
Expand All @@ -10,7 +11,6 @@ nvapi_src = files([
'../src/nvapi/nvapi_output.cpp',
'../src/nvapi/nvapi_adapter.cpp',
'../src/nvapi/nvapi_adapter_registry.cpp',
'../src/resource_factory.cpp',
'../src/nvapi/nvapi_d3d11_device.cpp',
'../src/nvapi/nvapi_d3d12_device.cpp',
'../src/nvapi_globals.cpp',
Expand Down
2 changes: 1 addition & 1 deletion tests/mock_factory.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "nvapi_tests_private.h"
#include "../src/resource_factory.h"
#include "../src/nvapi/resource_factory.h"

using namespace trompeloeil;

Expand Down