From 6fc2c37d9a4c408331db1b33deb3b46e74d2a7d2 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 12 Aug 2019 15:41:41 -0400 Subject: Callable CPU code support (#1014) * First pass support for compiling to a loaded shared library. * Improve documentation for cpu target. * Removed the SLANG_COMPILE_FLAG_LOAD_SHARED_LIBRARY flag. Use the SLANG_HOST_CALLABLE code target Document mechanism. * Fix typo in cpp-resource.slang In test code if the target is 'callable' we don't need to compile (indeed there is no source file). * Small refactor using CommandLineCPPCompiler as base class to implement VisualStudioCPPCompiler and GCCCPPCompiler. * Improvements around CPPCompiler. Mechanism to know products produced. Cleaning up products after execution. * Fix multiple definition of 'SourceType' --- slang.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'slang.h') diff --git a/slang.h b/slang.h index 281aeba6a..474ea9916 100644 --- a/slang.h +++ b/slang.h @@ -516,6 +516,7 @@ extern "C" SLANG_CPP_SOURCE, ///< The C++ language SLANG_EXECUTABLE, ///< Executable (for hosting CPU/OS) SLANG_SHARED_LIBRARY, ///< A shared library/Dll (for hosting CPU/OS) + SLANG_HOST_CALLABLE, ///< A CPU target that makes the compiled code available to be run immediately }; /* A "container format" describes the way that the outputs @@ -1210,6 +1211,8 @@ extern "C" int targetIndex, SlangTargetFlags flags); + + /*! @brief Set the floating point mode (e.g., precise or fast) to use a target. */ @@ -1547,6 +1550,7 @@ extern "C" /** Get the output code associated with a specific entry point. + @param request The request @param entryPointIndex The index of the entry point to get code for. @param targetIndex The index of the target to get code for (default: zero). @param outBlob A pointer that will receive the blob of code @@ -1560,14 +1564,36 @@ extern "C" int targetIndex, ISlangBlob** outBlob); + /** Get entry point 'callable' functions accessible through the ISlangSharedLibrary interface. + + That the functions remain in scope as long as the ISlangSharedLibrary interface is in scope. + + NOTE! Requires a compilation target of SLANG_HOST_CALLABLE. + + @param request The request + @param entryPointIndex The index of the entry point to get code for. + @param targetIndex The index of the target to get code for (default: zero). + @param outSharedLibrary A pointer to a ISharedLibrary interface which functions can be queried on. + @returns A `SlangResult` to indicate success or failure. + */ + SLANG_API SlangResult spGetEntryPointHostCallable( + SlangCompileRequest* request, + int entryPointIndex, + int targetIndex, + ISlangSharedLibrary** outSharedLibrary); + /** Get the output bytecode associated with an entire compile request. The lifetime of the output pointer is the same as `request`. + + DEPRECIATED: No longer outputs anything. */ SLANG_API void const* spGetCompileRequestCode( SlangCompileRequest* request, size_t* outSize); + + /* Forward declarations of types used in the reflection interface; */ -- cgit v1.2.3