Source browser
examples/plugin.cpp
Read the complete file below or download its original bytes. Line numbers provide stable links to a declaration or processing step.
File fingerprint
1#include "shdr.h" // Include shdr.h declarations.
2
3#if defined(_WIN32) // Select the platform or build feature required by this branch.
4#define SHDR_PLUGIN_EXPORT __declspec(dllexport) // Define SHDR_PLUGIN_EXPORT for the declarations that follow.
5#else // Select the alternative implementation for this build.
6#define SHDR_PLUGIN_EXPORT __attribute__((visibility("default"))) // Define SHDR_PLUGIN_EXPORT for the declarations that follow.
7#endif // Finish this conditional compilation branch.
8
9// The factory and destructor form this example's small C ABI.
10// Both sides still use the same C++ compiler/runtime and the same shdr header.
11extern "C" { // Expose predictable symbol names for the runtime module loader.
12SHDR_PLUGIN_EXPORT shdr::kernel* shdr_create_kernel() { // Export a factory for the native affine shader compiled into this module.
13 return shdr::make_kernel("affine_kernel").release(); // Transfer ownership of the registered kernel to the module caller.
14} // End this block.
15
16SHDR_PLUGIN_EXPORT void shdr_destroy_kernel(shdr::kernel* value) { // Export a destructor matching the factory's object allocation.
17 delete value; // Destroy the complete shader object while this module is still loaded.
18} // End this block.
19} // End this block.