diff options
author | Jens Peters <jp7677@gmail.com> | 2022-02-06 21:40:39 +0300 |
---|---|---|
committer | Jens Peters <jp7677@gmail.com> | 2022-02-06 21:40:39 +0300 |
commit | f17a75b443ba13acdf3ac02c8e9221aab43e69be (patch) | |
tree | 777e8b6f799ac0b76110f9b784f0833e9bb7d702 /tests | |
parent | 56279b5a471ed0248dc18dc7974a320f03a522a4 (diff) |
tests: Group GetResourceHandle tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/nvapi_d3d11.cpp | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/tests/nvapi_d3d11.cpp b/tests/nvapi_d3d11.cpp index ee5ab82..20e3866 100644 --- a/tests/nvapi_d3d11.cpp +++ b/tests/nvapi_d3d11.cpp @@ -296,31 +296,33 @@ TEST_CASE("D3D11 methods succeed", "[.d3d11]") { REQUIRE(contextRefCount == 0); } - SECTION("GetResourceHandle returns OK") { - // Test device call twice to ensure correct reference counting when hitting the device cache - D3D11BufferMock resource; - auto handle = reinterpret_cast<NVDX_ObjectHandle>(&resource); - REQUIRE(NvAPI_D3D11_GetResourceHandle(static_cast<ID3D11Device*>(&device), &resource, &handle) == NVAPI_OK); - REQUIRE(NvAPI_D3D11_GetResourceHandle(static_cast<ID3D11Device*>(&device), &resource, &handle) == NVAPI_OK); - REQUIRE(deviceRefCount == 0); - REQUIRE(contextRefCount == 0); - } - - SECTION("GetResourceHandle with NULL argument returns InvalidArgument") { - D3D11BufferMock resource; - NVDX_ObjectHandle handle; - REQUIRE(NvAPI_D3D11_GetResourceHandle(nullptr, &resource, &handle) == NVAPI_INVALID_ARGUMENT); - REQUIRE(NvAPI_D3D11_GetResourceHandle(static_cast<ID3D11Device*>(&device), nullptr, &handle) == NVAPI_INVALID_ARGUMENT); - REQUIRE(NvAPI_D3D11_GetResourceHandle(static_cast<ID3D11Device*>(&device), &resource, nullptr) == NVAPI_INVALID_ARGUMENT); - REQUIRE(deviceRefCount == 0); - REQUIRE(contextRefCount == 0); - } - - SECTION("GetResourceHandle output handle is a simple recast of the input resource pointer") { - // While the handles returned by NvAPI are opaque with unspecified values, our interaction with DXVK *requires* that we implement them as a simple recast - D3D11BufferMock resource; - NVDX_ObjectHandle handle; - REQUIRE(NvAPI_D3D11_GetResourceHandle(static_cast<ID3D11Device*>(&device), &resource, &handle) == NVAPI_OK); - REQUIRE(reinterpret_cast<void*>(handle) == reinterpret_cast<void*>(&resource)); + SECTION("GetResourceHandle succeeds") { + SECTION("GetResourceHandle returns OK") { + // Test device call twice to ensure correct reference counting when hitting the device cache + D3D11BufferMock resource; + auto handle = reinterpret_cast<NVDX_ObjectHandle>(&resource); + REQUIRE(NvAPI_D3D11_GetResourceHandle(static_cast<ID3D11Device*>(&device), &resource, &handle) == NVAPI_OK); + REQUIRE(NvAPI_D3D11_GetResourceHandle(static_cast<ID3D11Device*>(&device), &resource, &handle) == NVAPI_OK); + REQUIRE(deviceRefCount == 0); + REQUIRE(contextRefCount == 0); + } + + SECTION("GetResourceHandle with NULL argument returns InvalidArgument") { + D3D11BufferMock resource; + NVDX_ObjectHandle handle; + REQUIRE(NvAPI_D3D11_GetResourceHandle(nullptr, &resource, &handle) == NVAPI_INVALID_ARGUMENT); + REQUIRE(NvAPI_D3D11_GetResourceHandle(static_cast<ID3D11Device*>(&device), nullptr, &handle) == NVAPI_INVALID_ARGUMENT); + REQUIRE(NvAPI_D3D11_GetResourceHandle(static_cast<ID3D11Device*>(&device), &resource, nullptr) == NVAPI_INVALID_ARGUMENT); + REQUIRE(deviceRefCount == 0); + REQUIRE(contextRefCount == 0); + } + + SECTION("GetResourceHandle output handle is a simple recast of the input resource pointer") { + // While the handles returned by NVAPI are opaque with unspecified values, our interaction with DXVK *requires* that we implement them as a simple recast + D3D11BufferMock resource; + NVDX_ObjectHandle handle; + REQUIRE(NvAPI_D3D11_GetResourceHandle(static_cast<ID3D11Device*>(&device), &resource, &handle) == NVAPI_OK); + REQUIRE(reinterpret_cast<void*>(handle) == reinterpret_cast<void*>(&resource)); + } } } |