Database Function Calls

mi_db_create
void *mi_db_create(
    miTag * const   tag,
    const int       type,
    const int       size)

Create a data item with the specified size, and return a nonzero tag and a nonzero address (if size is 0, one byte is allocated to keep the item warm). Creating implies pinning. Calls mi_fatal and aborts on failure. The DB module always initializes new items with null bytes. The SCENE module offers calls to create certain database items, which must be used when available to create items with defaults. No module other than SCENE may call mi_db_create directly. The type must be specified for mi_db_type, and for debugging purposes. It must be between 1 and 255. See SCENE for type creation. mi_db_create is not normally used by applications that integrate raylib.

mi_db_copy
miTag mi_db_copy(
    const miTag     tag)

Create a duplicate of tag and return the tag of the duplicate. The duplicate has the same type and size, and the same contents as the source tag tag. The duplicate is not accessed, no unpin is required.

mi_db_type
int mi_db_type(
    const miTag     tag)

Returns the type that was specified when the item was created. This is done when an item needs to be byte-swapped; every type is swapped in a different way. Type 0 is illegal. See the type list miScene_types for a list of predefined internal database item types. The tag must exist.

mi_db_access
void *mi_db_access(
    const miTag     tag)

Look up the tag in the database, pin it, and return a pointer to the referenced item. This is an extremely popular function that must execute as fast as possible. mi_fatal is called and the program aborts if the given tag does not exist. mi_db_access always returns a valid pointer. If an item is accessed twice, it must be unpinned twice; pinned is a counter, not a flag. Translators that intend to modify an item must call mi_scene_edit instead; it is equivalent but sets a dirty flag for later scene preprocessing, and may create overlay buffers for concurrent incremental updates.

mi_db_access_type
void *mi_db_access_type(
    int * const     type,
    const miTag     tag)

Like mi_db_access and mi_db_type rolled into one. This is useful in cases where both the address and the type are required and two separate calls would be too slow. The returned type actually has a data type miScene_type but is declared as an integer to avoid a forward declaration.

mi_db_realloc
void *mi_db_realloc(
    const miTag     tag,
    const int       size)

Changes the size of an existing database item. The resized items will be unchanged up to the lesser of the old and the new size. If the new size is greater than the old size, the remainder is zeroed. A pointer to the resized item is returned; the caller may not use the old pointer it may have gotten from an earlier mi_db_create or mi_db_access on the same database item. If size is 0, one byte is allocated and a valid pointer to it is returned. Returns 0 on failure. Like mi_db_access, reallocation increments the pin count, and there must be a mi_db_unpin for every reallocation. After finishing with the reallocated item, the caller must flush the item to inform other hosts of the change. This call is intended for the SCENE module only. All other modules should call mi_scene_growedit. mi_db_realloc is not normally used by applications that integrate raylib.

mi_db_delete
void mi_db_delete(
    const miTag     tag)

Delete the item referenced by the tag. Modules that have the item pinned are seriously out of luck because their pointers become invalid. The item is deleted on the local host and on all other hosts. The caller should make sure that no other host still has this item pinned; if one does that host generates a warning. This call is intended for the SCENE module only. All other modules should call mi_scene_delete. mi_db_delete is not normally used by applications that integrate raylib.

mi_db_flush
void mi_db_flush(
    const miTag     tag)

Deprecated Notify all other hosts that have a copy of the item to invalidate or re-read their copy. Flushing is necessary after the caller finished writing to an entry. If the item was just created using mi_db_create, it is not necessary to flush it because no other host can possibly have a copy, because the tag is only known to the creating routine. If tag is 0, no item is flushed, but all deferred flushes (if any) are propagated to other CPUs. Note that flushes of items created on another host are less efficient than flushes of items created locally. The mi_scene_edit_end call flushes implicitly. This call should not be used because it interferes with job management.

mi_db_deferredflush
void mi_db_deferredflush(
    const miTag     tag)

Deprecated This call is equivalent to mi_db_flush, except that the tag may be buffered locally and sent as a block if either the buffer fills, or a regular mi_db_flush is called. If, for example, all materials are changed, it is far more efficient to call mi_db_deferredflush for each material followed by a single mi_db_flush (miNULLTAG) than to call mi_db_flush for each material. This call should not be used because it interferes with job management.

mi_db_unpin
void mi_db_unpin(
    const miTag     tag)

Unpin an item. The pointer returned by mi_db_access or mi_scene_edit may no longer be used. If the last pin is removed, the DB module is free to re-use the memory, provided that it is not the owner of the item (i.e., this is not the host where the item was created). This last restriction ensures that at least one copy of the item remains on the net of DBs. It is not allowed to unpin an item that is not pinned; development versions will abort with a failed assertion and production versions will silently ignore the extra unpin.

mi_db_dump
int mi_db_dump(
    const miModule  module)

This is a debugging function. It dumps all known database items to mi_info, with host ID, tag number, address, type, number of pins, and the module that created the database item. If the listed address is 0, the item is not in local memory. If module is nonzero (one of the miM_ constants), the listing is restricted to database items created by that module; if module is 0, all database items are listed.

Copyright © 1986, 2015 NVIDIA ARC GmbH. All rights reserved.