From bd4995b7ae63fe7cd3d7da631c59ee9828027b32 Mon Sep 17 00:00:00 2001 From: ns6089 <61738816+ns6089@users.noreply.github.com> Date: Tue, 20 Aug 2024 18:07:51 +0300 Subject: [PATCH] fixup! feat(win/nvenc): dynamic sdk version selection at runtime --- src/nvenc/win/nvenc_dynamic_factory.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/nvenc/win/nvenc_dynamic_factory.cpp b/src/nvenc/win/nvenc_dynamic_factory.cpp index 9eec300b851..0d76f5051b7 100644 --- a/src/nvenc/win/nvenc_dynamic_factory.cpp +++ b/src/nvenc/win/nvenc_dynamic_factory.cpp @@ -89,24 +89,24 @@ namespace { _COM_SMARTPTR_TYPEDEF(ID3D11Device, IID_ID3D11Device); } // namespace -struct NvencFactoryVersionTests: testing::TestWithParam { +struct NvencVersionTests: testing::TestWithParam { static void SetUpTestSuite() { std::tie(suite.dll, suite.max_version) = load_dll(); if (!suite.dll) GTEST_SKIP(); IDXGIFactory1Ptr dxgi_factory; - EXPECT_HRESULT_SUCCEEDED(CreateDXGIFactory1(IID_PPV_ARGS(&dxgi_factory))); + ASSERT_HRESULT_SUCCEEDED(CreateDXGIFactory1(IID_PPV_ARGS(&dxgi_factory))); IDXGIAdapterPtr dxgi_adapter; for (UINT i = 0; dxgi_factory->EnumAdapters(i, &dxgi_adapter) != DXGI_ERROR_NOT_FOUND; i++) { DXGI_ADAPTER_DESC desc; - EXPECT_HRESULT_SUCCEEDED(dxgi_adapter->GetDesc(&desc)); + ASSERT_HRESULT_SUCCEEDED(dxgi_adapter->GetDesc(&desc)); if (desc.VendorId == 0x10de) break; } if (!dxgi_adapter) GTEST_SKIP(); - EXPECT_HRESULT_SUCCEEDED(D3D11CreateDevice(dxgi_adapter, D3D_DRIVER_TYPE_UNKNOWN, NULL, 0, + ASSERT_HRESULT_SUCCEEDED(D3D11CreateDevice(dxgi_adapter, D3D_DRIVER_TYPE_UNKNOWN, NULL, 0, nullptr, 0, D3D11_SDK_VERSION, &suite.device, nullptr, nullptr)); } @@ -122,17 +122,17 @@ struct NvencFactoryVersionTests: testing::TestWithParam suite.max_version) GTEST_SKIP(); auto factory = factory_init(suite.dll); - EXPECT_TRUE(factory); + ASSERT_TRUE(factory); auto nvenc = factory->create_nvenc_d3d11_native(suite.device); - EXPECT_TRUE(nvenc); + ASSERT_TRUE(nvenc); video::config_t config = { .width = 1920, @@ -144,10 +144,13 @@ TEST_P(NvencFactoryVersionTests, CreateAndEncode) { .colorspace = video::colorspace_e::rec601, .bit_depth = 8, }; - EXPECT_TRUE(nvenc->create_encoder({}, config, colorspace, platf::pix_fmt_e::nv12)); - EXPECT_FALSE(nvenc->encode_frame(0, false).data.empty()); + ASSERT_TRUE(nvenc->create_encoder({}, config, colorspace, platf::pix_fmt_e::nv12)); + ASSERT_FALSE(nvenc->encode_frame(0, false).data.empty()); } -INSTANTIATE_TEST_SUITE_P(NvencFactoryTests, NvencFactoryVersionTests, testing::ValuesIn(factory_priorities)); +INSTANTIATE_TEST_SUITE_P(NvencFactoryTests, NvencVersionTests, testing::ValuesIn(factory_priorities), + [](const testing::TestParamInfo &info) { + return std::to_string(std::get<1>(info.param)); + }); #endif