-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
285 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#define CATCH_CONFIG_MAIN | ||
#include "../../inc/catch_amalgamated.hpp" | ||
#include "section_listener.h" | ||
|
||
CATCH_REGISTER_TAG_ALIAS("[@unit-tests]", "[d3d12],[vk]") | ||
CATCH_REGISTER_TAG_ALIAS("[@all]", "[d3d12],[vk]") | ||
|
||
CATCH_REGISTER_LISTENER(SectionListener) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include "nvofapi_tests_private.h" | ||
#include "../../src/shared/resource_factory.h" | ||
#include "../shared/vulkan_mocks.h" | ||
|
||
using namespace trompeloeil; | ||
|
||
class MockFactory final : public dxvk::ResourceFactory { | ||
|
||
public: | ||
MockFactory(std::unique_ptr<VkMock> vkMock) | ||
: m_vkMock(std::move(vkMock)) {}; | ||
|
||
std::unique_ptr<dxvk::Vk> CreateVulkan(const char*) override { | ||
return std::move(m_vkMock); | ||
} | ||
|
||
private: | ||
std::unique_ptr<VkMock> m_vkMock; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "nvofapi_tests_private.h" | ||
#include "mock_factory.h" | ||
#include "../shared/vulkan_mocks.h" | ||
#include "../shared/d3d12_mocks.h" | ||
|
||
using namespace trompeloeil; | ||
|
||
TEST_CASE("D3D12 methods succeed", "[.d3d12][!mayfail]") { | ||
SECTION("CreateInstanceD3D12 fails to initialize with major version other than 5") { | ||
NV_OF_D3D12_API_FUNCTION_LIST functionList{}; | ||
REQUIRE(NvOFAPICreateInstanceD3D12(0, &functionList) == NV_OF_ERR_INVALID_VERSION); | ||
} | ||
|
||
SECTION("CreateInstanceD3D12 initializes") { | ||
auto vk = std::make_unique<VkMock>(); | ||
auto vkDevice = std::make_unique<VkDeviceMock>(); | ||
|
||
NV_OF_D3D12_API_FUNCTION_LIST functionList{}; | ||
REQUIRE(NvOFAPICreateInstanceD3D12(80, &functionList) == NV_OF_SUCCESS); | ||
|
||
SECTION("CreateInstanceVk fails to initialize when Vulkan is not available") { | ||
ALLOW_CALL(*vk, IsAvailable()).RETURN(false); | ||
FORBID_CALL(*vk, GetInstanceProcAddr(_, _)); | ||
FORBID_CALL(*vk, GetDeviceProcAddr(_, _)); | ||
|
||
resourceFactory = std::make_unique<MockFactory>(std::move(vk)); | ||
|
||
D3D12Vkd3dDeviceMock device; | ||
NvOFHandle hOFInstance; | ||
REQUIRE(functionList.nvCreateOpticalFlowD3D12(static_cast<ID3D12Device*>(&device), &hOFInstance) == NV_OF_ERR_GENERIC); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
|
||
#if defined(__GNUC__) || defined(__clang__) | ||
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" | ||
#endif // defined(__GNUC__) || defined(__clang__) | ||
|
||
#include "../../src/nvofapi_private.h" | ||
#include "../../src/nvofapi_globals.h" | ||
|
||
#include "../../inc/catch_amalgamated.hpp" | ||
#include "../../inc/catch2/trompeloeil.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "nvofapi_tests_private.h" | ||
#include "mock_factory.h" | ||
#include "../shared/vulkan_mocks.h" | ||
|
||
using namespace trompeloeil; | ||
|
||
TEST_CASE("Vk methods succeed", "[.vk][!mayfail]") { | ||
|
||
SECTION("CreateInstanceVk fails to initialize with major version other than 5") { | ||
NV_OF_VK_API_FUNCTION_LIST functionList{}; | ||
REQUIRE(NvOFAPICreateInstanceVk(0, &functionList) == NV_OF_ERR_INVALID_VERSION); | ||
} | ||
|
||
SECTION("CreateInstanceVk initializes") { | ||
auto vk = std::make_unique<VkMock>(); | ||
auto vkDevice = std::make_unique<VkDeviceMock>(); | ||
|
||
NV_OF_VK_API_FUNCTION_LIST functionList{}; | ||
REQUIRE(NvOFAPICreateInstanceVk(80, &functionList) == NV_OF_SUCCESS); | ||
|
||
SECTION("CreateInstanceVk fails to initialize when Vulkan is not available") { | ||
ALLOW_CALL(*vk, IsAvailable()).RETURN(false); | ||
FORBID_CALL(*vk, GetInstanceProcAddr(_, _)); | ||
FORBID_CALL(*vk, GetDeviceProcAddr(_, _)); | ||
|
||
resourceFactory = std::make_unique<MockFactory>(std::move(vk)); | ||
|
||
VkInstance vkInstance{}; | ||
VkPhysicalDevice vkPhysicalDevice{}; | ||
NvOFHandle hOFInstance; | ||
REQUIRE(functionList.nvCreateOpticalFlowVk(vkInstance, vkPhysicalDevice, reinterpret_cast<VkDevice>(vkDevice.get()), &hOFInstance) == NV_OF_ERR_GENERIC); | ||
} | ||
|
||
SECTION("CreateInstanceVk returns success") { | ||
ALLOW_CALL(*vk, IsAvailable()).RETURN(true); | ||
FORBID_CALL(*vk, GetInstanceProcAddr(_, _)); | ||
FORBID_CALL(*vk, GetDeviceProcAddr(_, _)); | ||
|
||
resourceFactory = std::make_unique<MockFactory>(std::move(vk)); | ||
|
||
VkInstance vkInstance{}; | ||
VkPhysicalDevice vkPhysicalDevice{}; | ||
NvOFHandle hOFInstance; | ||
REQUIRE(functionList.nvCreateOpticalFlowVk(vkInstance, vkPhysicalDevice, reinterpret_cast<VkDevice>(vkDevice.get()), &hOFInstance) == NV_OF_SUCCESS); | ||
} | ||
} | ||
} |
Oops, something went wrong.