Skip to content

Commit

Permalink
nvofapi: NvOFAPICreateInstanceCuda - stub
Browse files Browse the repository at this point in the history
This will return NV_OF_ERR_OF_NOT_AVAILABLE for NvOFAPICreateInstanceCuda

Signed-off-by: Sveinar Søpler <[email protected]>
  • Loading branch information
SveSop committed Feb 2, 2025
1 parent c8c60a4 commit b0208db
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ nvofapi_src = files([
'nvofapi.cpp',
'nvofapi_d3d12.cpp',
'nvofapi_vk.cpp',
'nvofapi_cuda.cpp',
])

# Only build 64-bit versions of nvofapi
Expand Down
17 changes: 17 additions & 0 deletions src/nvofapi_cuda.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "nvofapi_private.h"
#include "util/util_log.h"
#include "util/util_statuscode.h"

extern "C" {

using namespace dxvk;

NV_OF_STATUS __cdecl NvOFAPICreateInstanceCuda(uint32_t apiVer, void* functionList) {
constexpr auto n = __func__;

if (log::tracing())
log::trace(n, apiVer, log::fmt::ptr(functionList));

return OFNotAvailable(n);
}
}
3 changes: 3 additions & 0 deletions src/nvofapi_entrypoints.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ extern "C" {
NV_OF_STATUS NVOFAPI OFSessionGetLastError(NvOFHandle hOf, char lastError[], uint32_t* size);

NV_OF_STATUS NVOFAPI OFSessionGetCaps(NvOFHandle hOf, NV_OF_CAPS capsParam, uint32_t* capsVal, uint32_t* size);

// Overwrite CUDA entrypoint to avoid dependency to cuda.h
NV_OF_STATUS NVOFAPI NvOFAPICreateInstanceCuda(uint32_t apiVer, void* functionList);
}
2 changes: 2 additions & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ nvofapi_src = files([
'../src/nvofapi.cpp',
'../src/nvofapi_d3d12.cpp',
'../src/nvofapi_vk.cpp',
'../src/nvofapi_cuda.cpp',
])

nvofapi_tests_src = files([
'nvofapi_main.cpp',
'nvofapi_d3d12.cpp',
'nvofapi_vk.cpp',
'nvofapi_cuda.cpp',
])

target_name = 'nvofapi'+target_suffix+'-tests'
Expand Down
9 changes: 9 additions & 0 deletions tests/nvofapi_cuda.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "nvofapi_tests_private.h"
#include "nvofapi/mock_factory.h"

using namespace trompeloeil;

TEST_CASE("CreateInstanceVk returns not-available", "[.cuda]") {
struct NV_OF_CUDA_API_FUNCTION_LIST{} functionList;
REQUIRE(NvOFAPICreateInstanceCuda(80, &functionList) == NV_OF_ERR_OF_NOT_AVAILABLE);
}
4 changes: 2 additions & 2 deletions tests/nvofapi_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "../inc/catch_amalgamated.hpp"
#include "nvofapi/section_listener.h"

CATCH_REGISTER_TAG_ALIAS("[@unit-tests]", "[d3d12],[vk]")
CATCH_REGISTER_TAG_ALIAS("[@all]", "[d3d12],[vk]")
CATCH_REGISTER_TAG_ALIAS("[@unit-tests]", "[d3d12],[vk],[cuda]")
CATCH_REGISTER_TAG_ALIAS("[@all]", "[d3d12],[vk],[cuda]")

CATCH_REGISTER_LISTENER(SectionListener)
1 change: 1 addition & 0 deletions tests/nvofapi_tests_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#endif // defined(__GNUC__) || defined(__clang__)

#include "../src/nvofapi_private.h"
#include "../src/nvofapi_entrypoints.h"
#include "../src/nvofapi_globals.h"

#include "../inc/catch_amalgamated.hpp"
Expand Down

0 comments on commit b0208db

Please sign in to comment.