Types.h#
Fully qualified name: carb/Types.h
File members: carb/Types.h
// Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Interface.h"
#include "Strong.h"
#include "../omni/core/OmniAttr.h"
#include <cstddef>
#include <cstdint>
namespace omni
{
namespace core
{
OMNI_DECLARE_INTERFACE(ITypeFactory) // forward declaration for entry inPluginFrameworkDesc
}
namespace log
{
class ILog; // forward declaration for entry in PluginFrameworkDesc
}
namespace structuredlog
{
class IStructuredLog;
}
} // namespace omni
namespace carb
{
enum class PluginHotReload
{
eDisabled,
eEnabled
};
struct PluginImplDesc
{
const char* name;
const char* description;
const char* author;
PluginHotReload hotReload;
const char* build;
};
CARB_ASSERT_INTEROP_SAFE(PluginImplDesc);
struct PluginRegistryEntry
{
PluginImplDesc implDesc;
struct Interface
{
InterfaceDesc desc;
const void* ptr;
size_t size;
};
Interface* interfaces;
size_t interfaceCount;
};
CARB_ASSERT_INTEROP_SAFE(PluginRegistryEntry);
CARB_ASSERT_INTEROP_SAFE(PluginRegistryEntry::Interface);
struct PluginRegistryEntry2
{
size_t sizeofThisStruct;
PluginImplDesc implDesc;
struct Interface2
{
size_t sizeofThisStruct;
InterfaceDesc desc;
size_t size;
size_t align;
void(CARB_ABI* Constructor)(void* p);
union
{
void(CARB_ABI* Destructor)(void* p);
void(CARB_ABI* VersionedDestructor)(Version v, void* p);
};
bool(CARB_ABI* VersionedConstructor)(Version* v, void* p);
// Internal note: This struct can be modified via the same rules for PluginRegistryEntry2 below.
};
Interface2* interfaces;
size_t interfaceCount;
// Internal note: This struct can be modified without changing the carbonite framework version, provided that new
// members are only added to the end of the struct and existing members are not modified. The version can then be
// determined by the sizeofThisStruct member. However, if it is modified, please add a new
// carb.frameworktest.*.plugin (see ex2initial in premake5.lua for an example).
};
CARB_ASSERT_INTEROP_SAFE(PluginRegistryEntry2);
CARB_ASSERT_INTEROP_SAFE(PluginRegistryEntry2::Interface2);
struct PluginDesc
{
PluginImplDesc impl;
const InterfaceDesc* interfaces;
size_t interfaceCount;
const InterfaceDesc* dependencies;
size_t dependencyCount;
const char* libPath;
};
CARB_ASSERT_INTEROP_SAFE(PluginDesc);
enum class PluginReloadState
{
eBefore,
eAfter
};
struct PluginFrameworkDesc
{
struct Framework* framework;
omni::core::ITypeFactory* omniTypeFactory;
omni::log::ILog* omniLog;
omni::structuredlog::IStructuredLog* omniStructuredLog;
void* Reserved[28];
};
static_assert(sizeof(PluginFrameworkDesc) == (sizeof(void*) * 32),
"sizeof(PluginFrameworkDesc) is unexpected. did you add a new field improperly?"); // contact ncournia for
// questions
struct CARB_ALIGN_AS(8) SharedHandle
{
union
{
void* handlePointer;
void* handleWin32;
int handleFd;
};
};
//
typedef Version(CARB_ABI* GetFrameworkVersionFn)();
typedef void(CARB_ABI* OnPluginRegisterFn)(Framework* framework, PluginRegistryEntry* outEntry);
typedef void(CARB_ABI* OnPluginRegisterExFn)(PluginFrameworkDesc* framework, PluginRegistryEntry* outEntry);
typedef void(CARB_ABI* OnPluginRegisterEx2Fn)(PluginFrameworkDesc* framework, PluginRegistryEntry2* outEntry);
typedef void(CARB_ABI* OnPluginPreStartupFn)();
typedef void(CARB_ABI* OnPluginStartupFn)();
typedef bool(CARB_ABI* OnPluginStartupExFn)();
typedef void(CARB_ABI* OnPluginShutdownFn)();
typedef void(CARB_ABI* OnPluginQuickShutdownFn)();
typedef void(CARB_ABI* OnPluginPostShutdownFn)();
typedef void(CARB_ABI* GetPluginDepsFn)(InterfaceDesc** interfaceDesc, size_t* count);
typedef void(CARB_ABI* OnReloadDependencyFn)(PluginReloadState reloadState, void* pluginInterface, PluginImplDesc desc);
struct Float2
{
float x;
float y;
};
struct Float3
{
float x;
float y;
float z;
};
struct Float4
{
float x;
float y;
float z;
float w;
};
struct Double2
{
double x;
double y;
};
struct Double3
{
double x;
double y;
double z;
};
struct Double4
{
double x;
double y;
double z;
double w;
};
template <typename T>
struct Color
{
T r;
T g;
T b;
T a;
};
struct ColorRgb
{
float r;
float g;
float b;
};
struct ColorRgba
{
float r;
float g;
float b;
float a;
};
struct ColorRgbDouble
{
double r;
double g;
double b;
};
struct ColorRgbaDouble
{
double r;
double g;
double b;
double a;
};
struct Int2
{
int32_t x;
int32_t y;
};
struct Int3
{
int32_t x;
int32_t y;
int32_t z;
};
struct Int4
{
int32_t x;
int32_t y;
int32_t z;
int32_t w;
};
struct Uint2
{
uint32_t x;
uint32_t y;
};
struct Uint3
{
uint32_t x;
uint32_t y;
uint32_t z;
};
struct Uint4
{
uint32_t x;
uint32_t y;
uint32_t z;
uint32_t w;
};
using FourCC = uint32_t;
#define CARB_MAKE_FOURCC(a, b, c, d) \
((FourCC)(uint8_t)(a) | ((FourCC)(uint8_t)(b) << 8) | ((FourCC)(uint8_t)(c) << 16) | ((FourCC)(uint8_t)(d) << 24))
constexpr uint32_t kTimeoutInfinite = CARB_UINT32_MAX;
CARB_STRONGTYPE(LoadHookHandle, size_t);
constexpr LoadHookHandle kInvalidLoadHook{};
CARB_STRONGTYPE(RegisterHookHandle, size_t);
constexpr RegisterHookHandle kInvalidRegisterHook{};
enum class BindingType : uint32_t
{
Owner,
Binding,
};
} // namespace carb
// these types used to be in this file but didn't really belong. we continue to include these type in this file for
// backward-compat.
#include "RenderingTypes.h"