Skip to content

Native access

RI exposes the underlying Vulkan and D3D12 objects so you can use features RI does not wrap, such as a new extension or an experimental D3D12 feature.

Native access is gated: RI's portable headers (<RI/RI.hpp> and the headers it includes) contain no Vulkan or D3D12 types. To reach native objects, you must do both of the following:

  1. Include the backend's native header: <RI/Vk/Native.hpp> for Vulkan or <RI/D3D12/Native.hpp> for D3D12.
  2. Qualify the call with the backend namespace, such as RI::Vk::native(device) or RI::D3D12::native(device), rather than RI::native(device). Including <RI/RI.hpp> alone does not bring native functions into RI::.

Code that must compile on both backends guards each backend-specific section with #if EQUINE_BACKEND_VULKAN or #elif EQUINE_BACKEND_D3D12 (the build defines the macro for whichever backend the target links):

#include <RI/RI.hpp>
#if EQUINE_BACKEND_VULKAN
#include <RI/Vk/Native.hpp>
#elif EQUINE_BACKEND_D3D12
#include <RI/D3D12/Native.hpp>
#endif
void printNativeDevice(const RI::Device &device) {
#if EQUINE_BACKEND_VULKAN
    const VkDevice native = RI::Vk::native(device).device;
#elif EQUINE_BACKEND_D3D12
    const ID3D12Device *native = RI::D3D12::native(device).device;
#endif
    std::printf("native device: %p\n", static_cast<const void *>(native));
}

Native code for one backend fails to compile when building for the other, so an unguarded call is caught at build time.

Pages

Backend Page What you can do
Vulkan Device creation Change the features RI enables (for example, robustness), add Vulkan extensions and pNext feature structures, or reach the instance, physical device, device, queue, and device function table.
Vulkan Native handles Retrieve the VkDeviceMemory, VkBuffer, VkImage (and resting layout), VkImageView, descriptor sets, VkQueryPool, pipeline, and command buffer behind RI objects.
D3D12 Device creation Run a callback just before D3D12CreateDevice (for example, to enable experimental features), or reach the DXGI factory, adapter, device, and command queue.
D3D12 Native objects Retrieve the ID3D12Heap, ID3D12Resource (and resting layout for textures), descriptor heaps, query heap, pipeline state, root signature, and command list behind RI objects.
Both Native sections Record native commands in the middle of an RI command list with beginNative and endNative.
Both Importing native objects Wrap natively created memory, buffers, textures, and pipelines as RI objects, and write native descriptors into a heap.