Loom C API
Public Loom compiler C API
Loading...
Searching...
No Matches
vulkan.h File Reference

Raw Vulkan SPIR-V profile adapter. More...

Go to the source code of this file.

Data Structures

struct  loomc_spirv_vulkan_function_table_t
 Vulkan query functions used by the raw Vulkan SPIR-V profile adapter. More...
struct  loomc_spirv_vulkan_profile_options_t
 Raw Vulkan profile creation options. More...

Functions

loomc_status_t loomc_target_profile_create_spirv_vulkan (loomc_target_environment_t *target_environment, const loomc_spirv_vulkan_profile_options_t *options, loomc_allocator_t allocator, loomc_target_profile_t **out_profile, loomc_result_t **out_result)
 Creates a SPIR-V target profile from a raw Vulkan physical device.

Detailed Description

Raw Vulkan SPIR-V profile adapter.

This optional leaf derives normalized SPIR-V profile facts from a caller-owned VkPhysicalDevice and a small table of Vulkan query functions. It includes Vulkan headers but does not load or link a Vulkan loader. Embedders that already own an instance/device stack can pass their resolved function pointers directly, while offline and cross-compilation flows can keep using header-light profile facts or saved vulkaninfo importers.

The adapter is a convenience layer over loomc_target_profile_create_spirv. It does not expose a second target model: queried Vulkan properties and features are normalized into the same feature, limit, and environment fact rows used by saved profiles and programmatic profile construction.

Example
Create a profile from a live Vulkan physical device:
.structure_size = sizeof(loomc_spirv_vulkan_function_table_t),
.get_physical_device_properties2 =
resolved_vkGetPhysicalDeviceProperties2,
.get_physical_device_features2 = resolved_vkGetPhysicalDeviceFeatures2,
.enumerate_device_extension_properties =
resolved_vkEnumerateDeviceExtensionProperties,
};
.structure_size = sizeof(loomc_spirv_vulkan_profile_options_t),
.identifier = loomc_make_cstring_view("live-vulkan-device"),
.physical_device = physical_device,
.functions = &functions,
};
loomc_target_profile_t* profile = NULL;
loomc_result_t* result = NULL;
target_environment, &options, loomc_allocator_system(), &profile,
&result);
if (!loomc_status_is_ok(status)) return status;
if (!loomc_result_succeeded(result)) {
// Inspect result diagnostics; profile is NULL on profile failure.
} else {
// Use profile for per-function specialization or further refinement.
}
loomc_allocator_t loomc_allocator_system(void)
Returns a process-global system allocator.
@ LOOMC_STRUCTURE_TYPE_SPIRV_VULKAN_FUNCTION_TABLE
loomc_spirv_vulkan_function_table_t.
Definition base.h:246
@ LOOMC_STRUCTURE_TYPE_SPIRV_VULKAN_PROFILE_OPTIONS
loomc_spirv_vulkan_profile_options_t.
Definition base.h:249
struct iree_status_handle_t * loomc_status_t
Opaque status handle.
Definition base.h:55
void loomc_result_release(loomc_result_t *result)
Releases result from one owner.
bool loomc_result_succeeded(const loomc_result_t *result)
Returns true when result succeeded.
struct loomc_result_t loomc_result_t
Immutable operation result.
Definition result.h:63
Vulkan query functions used by the raw Vulkan SPIR-V profile adapter.
Definition vulkan.h:68
Raw Vulkan profile creation options.
Definition vulkan.h:96
void loomc_target_profile_release(loomc_target_profile_t *profile)
Releases a target profile from one owner.
struct loomc_target_profile_t loomc_target_profile_t
Prepared immutable target profile.
Definition target.h:135
loomc_status_t loomc_target_profile_create_spirv_vulkan(loomc_target_environment_t *target_environment, const loomc_spirv_vulkan_profile_options_t *options, loomc_allocator_t allocator, loomc_target_profile_t **out_profile, loomc_result_t **out_result)
Creates a SPIR-V target profile from a raw Vulkan physical device.

Function Documentation

◆ loomc_target_profile_create_spirv_vulkan()

loomc_status_t loomc_target_profile_create_spirv_vulkan ( loomc_target_environment_t * target_environment,
const loomc_spirv_vulkan_profile_options_t * options,
loomc_allocator_t allocator,
loomc_target_profile_t ** out_profile,
loomc_result_t ** out_result )

Creates a SPIR-V target profile from a raw Vulkan physical device.

Parameters
target_environmentSPIR-V-capable target environment.
optionsVulkan physical device and function table. Required.
allocatorHost allocator used for profile and result storage.
out_profileReceives one retained profile when out_result succeeds.
out_resultReceives one retained result describing profile preparation.
Returns
OK when the Vulkan query and profile preparation completed far enough to report a result. Non-OK statuses represent API misuse or infrastructure failures before a result could be produced.

The adapter queries core physical-device properties and feature structs, plus extension structs exposed by the Vulkan headers used to build this leaf. Unsupported or header-absent facts remain unknown. Recognized queried facts use vulkan: provenance strings and are then validated by the shared SPIR-V profile layer.

Ownership
The caller owns out_profile when the returned result succeeds and releases it with loomc_target_profile_release. The caller always owns out_result on an OK return and releases it with loomc_result_release.
Thread safety
The adapter does not retain the Vulkan physical device or function table. Concurrent calls are safe when the caller's Vulkan implementation allows the supplied query functions to run concurrently for the supplied physical device.