Skip to content

Commit

Permalink
fixup! feat(win/nvenc): dynamic sdk version selection at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
ns6089 committed Aug 20, 2024
1 parent e21dedd commit bd4995b
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/nvenc/win/nvenc_dynamic_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,24 @@ namespace {
_COM_SMARTPTR_TYPEDEF(ID3D11Device, IID_ID3D11Device);
} // namespace

struct NvencFactoryVersionTests: testing::TestWithParam<decltype(factory_priorities)::value_type> {
struct NvencVersionTests: testing::TestWithParam<decltype(factory_priorities)::value_type> {
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));
}

Expand All @@ -122,17 +122,17 @@ struct NvencFactoryVersionTests: testing::TestWithParam<decltype(factory_priorit
} suite;
};

NvencFactoryVersionTests::Suite NvencFactoryVersionTests::suite = {};
NvencVersionTests::Suite NvencVersionTests::suite = {};

TEST_P(NvencFactoryVersionTests, CreateAndEncode) {
TEST_P(NvencVersionTests, CreateAndEncode) {
auto [factory_init, version] = GetParam();
if (version > 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,
Expand All @@ -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<NvencVersionTests::ParamType> &info) {
return std::to_string(std::get<1>(info.param));
});

#endif

0 comments on commit bd4995b

Please sign in to comment.