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

Saved vulkaninfo profile importer for SPIR-V targets. More...

Go to the source code of this file.

Data Structures

struct  loomc_spirv_vulkaninfo_profile_options_t
 Saved vulkaninfo profile import options. More...

Functions

loomc_status_t loomc_target_profile_create_spirv_vulkaninfo (loomc_target_environment_t *target_environment, const loomc_source_t *source, const loomc_spirv_vulkaninfo_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 saved vulkaninfo JSON.

Detailed Description

Saved vulkaninfo profile importer for SPIR-V targets.

This leaf translates saved Vulkan profile data into normalized SPIR-V profile facts. It does not include Vulkan headers, load a Vulkan loader, or require hardware. The importer accepts immutable loomc_source_t handles so embedders can choose borrowed, copied, memory-mapped, cached, or binding-owned storage using the ordinary source API. Filesystem input should be loaded with loomc_source_create_from_path and then passed to this importer.

The imported facts are intentionally the same public fact rows accepted by loomc_target_profile_create_spirv. The importer is a convenience adapter, not a separate target model. Unknown JSON fields are ignored. Recognized malformed fields produce SPIRV/VULKANINFO diagnostics on the returned result. Contradictory or unsupported normalized facts are then diagnosed by the SPIR-V profile layer using SPIRV/PROFILE diagnostics.

Example
Import a saved profile from caller-owned bytes:
loomc_source_options_t source_options = {
.structure_size = sizeof(loomc_source_options_t),
.identifier = loomc_make_cstring_view("vulkaninfo.json"),
.contents = loomc_make_byte_span(json_data, json_data_length),
};
loomc_source_t* source = NULL;
&source_options, loomc_allocator_system(), &source);
if (!loomc_status_is_ok(status)) return status;
.structure_size = sizeof(loomc_spirv_vulkaninfo_profile_options_t),
.identifier = loomc_make_cstring_view("offline-vulkan-profile"),
};
loomc_target_profile_t* profile = NULL;
loomc_result_t* result = NULL;
target_environment, source, &import_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 import failure.
}
loomc_allocator_t loomc_allocator_system(void)
Returns a process-global system allocator.
@ LOOMC_STRUCTURE_TYPE_SPIRV_VULKANINFO_PROFILE_OPTIONS
loomc_spirv_vulkaninfo_profile_options_t.
Definition base.h:240
@ LOOMC_STRUCTURE_TYPE_SOURCE_OPTIONS
loomc_source_options_t.
Definition base.h:186
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
@ LOOMC_SOURCE_STORAGE_BORROWED
Source bytes are borrowed from the caller for the lifetime of the source.
Definition source.h:97
void loomc_source_release(loomc_source_t *source)
Releases source from one owner.
struct loomc_source_t loomc_source_t
Immutable source handle.
Definition source.h:80
@ LOOMC_SOURCE_FORMAT_UNKNOWN
Source format is unknown and must be inferred by the consumer.
Definition source.h:85
loomc_status_t loomc_source_create(const loomc_source_options_t *options, loomc_allocator_t allocator, loomc_source_t **out_source)
Creates an immutable source handle.
Source creation options.
Definition source.h:123
Saved vulkaninfo profile import options.
Definition vulkaninfo.h:70
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_vulkaninfo(loomc_target_environment_t *target_environment, const loomc_source_t *source, const loomc_spirv_vulkaninfo_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 saved vulkaninfo JSON.

Function Documentation

◆ loomc_target_profile_create_spirv_vulkaninfo()

loomc_status_t loomc_target_profile_create_spirv_vulkaninfo ( loomc_target_environment_t * target_environment,
const loomc_source_t * source,
const loomc_spirv_vulkaninfo_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 saved vulkaninfo JSON.

Parameters
target_environmentSPIR-V-capable target environment.
sourceImmutable JSON/JSONC source bytes.
optionsImport options, or NULL for defaults.
allocatorHost allocator used for profile and result storage.
out_profileReceives one retained profile when out_result succeeds.
out_resultReceives one retained result describing import and profile preparation.
Returns
OK when import ran far enough to report a result. Non-OK statuses represent API misuse or infrastructure failures before a result could be produced.

Supported input shapes are the common raw vulkaninfo shape with a top-level devices array and the GPUInfo/Vulkan Profiles wrapper shape with top-level capabilities and profiles objects. The importer recognizes currently modeled Loom facts only; unrecognized Vulkan fields are ignored so newer saved profiles remain loadable by older Loom builds.

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.
Lifetime
The returned profile and result do not borrow from source. Diagnostics retain source when they reference imported JSON.
Thread safety
The importer only reads source and target_environment; concurrent imports using shared immutable handles are safe.