|
Kanzi Graphics Engine
|
KzuResource is the base class for all resource objects in the Engine. More...
#include "kzu_resource_common.h"#include <system/debug/kzs_error.h>#include <system/debug/kzs_profiling.h>#include <system/kzs_types.h>#include <system/kzs_header.h>Enumerations | |
| enum | KzuResourceLoadingStrategy { KZU_RESOURCE_LOADING_STRATEGY_DEFAULT, KZU_RESOURCE_LOADING_STRATEGY_MANUAL, KZU_RESOURCE_LOADING_STRATEGY_OPTIMIZE_SPEED, KZU_RESOURCE_LOADING_STRATEGY_OPTIMIZE_MEMORY, KZU_RESOURCE_LOADING_STRATEGY_ON_DEMAND } |
| Resource loading strategy specifies when the resource is loaded and unloaded. More... | |
Functions | |
| kzsError | kzuResourceCreateKZBLoader (const struct KzcMemoryManager *memoryManager, const struct KzuBinaryDirectory *binaryDirectory, kzString path, struct KzuResourceLoader **out_resourceLoader) |
| Creates the resource loader that loads the resource from the project file (.KZB) using the given path. More... | |
| kzsError | kzuResourceDelete (struct KzuResource *resource) |
| Deletes the resource. More... | |
| kzBool | kzuResourceTypeIsTypeOf (const KzuResourceType resourceType, const KzuResourceType baseResourceType) |
| Checks whether the resourceType, or one of its base types, is of the given base resource type. More... | |
| kzBool | kzuResourceIsTypeOf (const struct KzuResource *resource, const KzuResourceType resourceType) |
| Checks whether the resource, or one of its base types, is of the given resource type. More... | |
| KzuResourceType | kzuResourceGetType (const struct KzuResource *resource) |
| Returns the type of the resource. More... | |
| kzString | kzuResourceTypeGetName (KzuResourceType resourceType) |
| Returns the resource type name as a string. More... | |
| kzString | kzuResourceGetName (const struct KzuResource *resource) |
| Returns the name of the resource as a string. More... | |
| struct KzuResourceManager * | kzuResourceGetResourceManager (const struct KzuResource *resource) |
| Returns the resource manager that was used for creating the resource. More... | |
| kzsError | kzuResourceLoad (struct KzuResource *resource) |
| Loads the resource if the resource is not loaded. More... | |
| kzsError | kzuResourceUnload (struct KzuResource *resource) |
| Unloads the resource if the resource is loaded. More... | |
| kzBool | kzuResourceIsLoaded (const struct KzuResource *resource) |
| Checks whether the resource is loaded. More... | |
| enum KzuResourceLoadingStrategy | kzuResourceGetLoadingStrategy (const struct KzuResource *resource) |
| Returns the loading strategy of the resource. More... | |
| void | kzuResourceSetLoadingStrategy (struct KzuResource *resource, enum KzuResourceLoadingStrategy loadingStrategy) |
| Sets the loading strategy of the resource. More... | |
| kzUint | kzuResourceGetCPUMemoryUsage (const struct KzuResource *resource) |
| Returns the amount of memory used by the resource. More... | |
| kzsError | kzuResourceAcquire (struct KzuResource *resource) |
| Acquires an existing resource, increasing the reference count by one. More... | |
| kzsError | kzuResourceRelease (struct KzuResource *resource) |
| Decreases the reference count of a resource by one, effectively releases the resource when the reference count reaches zero. More... | |
| kzsError | kzuResourceLoad_private (struct KzuResource *resource, const struct KzuResourceLoaderThreadContext *threadContext) |
| Private function for kzuResourceLoad() with specified thread context. More... | |
| kzsError | kzuResourceFinishLoading_private (struct KzuResource *resource, const struct KzuResourceLoaderThreadContext *threadContext) |
| Private function for finishing the loading of the resource. More... | |
Variables | |
| const KzuResourceType | KZU_RESOURCE_TYPE_RESOURCE |
| Base resource type identifier for all resources. More... | |
KzuResource is the base class for all resource objects in the Engine.
The main functionality is to provide:
Loading and unloading of resource data is controlled by a KzuResourceManager, which uses KzuResourceLoadingStrategy of the resource to determine when the data should be loaded or unloaded.
User can derive this class using the API provided by kzu_resource_base.h.
Copyright 2008-2019 by Rightware. All rights reserved.
| #define KZU_RESOURCE_PROFILING_MESH_KZB |
Profiling tag for mesh.
| #define KZU_RESOURCE_PROFILING_MESH_DEPLOY |
Profiling tag for mesh deploy.
| #define KZU_RESOURCE_PROFILING_TEXTURE_2D_KZB |
Profiling tag for 2d texture.
| #define KZU_RESOURCE_PROFILING_TEXTURE_2D_DEPLOY |
Profiling tag for 2d texture deploy.
| #define KZU_RESOURCE_PROFILING_TEXTURE_CUBE_KZB |
Profiling tag for cubemap texture.
| #define KZU_RESOURCE_PROFILING_TEXTURE_CUBE_DEPLOY |
Profiling tag for cubemap texture deploy.
| #define KZU_RESOURCE_PROFILING_TEXTURE_RENDER_TARGET_2D_KZB |
Profiling tag for 2d render target texture.
| #define KZU_RESOURCE_PROFILING_TEXTURE_RENDER_TARGET_2D_DEPLOY |
Profiling tag for 2d render target texture deploy.
| #define KZU_RESOURCE_PROFILING_TEXTURE_RENDER_TARGET_CUBE_KZB |
Profiling tag for cubemap render target texture.
| #define KZU_RESOURCE_PROFILING_TEXTURE_RENDER_TARGET_CUBE_DEPLOY |
Profiling tag for cubemap render target texture deploy.
| #define KZU_RESOURCE_PROFILING_SHADER_KZB |
Profiling tag for shader.
| #define KZU_RESOURCE_PROFILING_SHADER_DEPLOY |
Profiling tag for shader deploy.
| #define KZU_RESOURCE_PROFILING_MATERIAL_KZB |
Profiling tag for material.
| #define KZU_RESOURCE_PROFILING_STYLE_KZB |
Profiling tag for style.
| #define KZU_RESOURCE_PROFILING_STATE_MANAGER_KZB |
Profiling tag for state manager.
| #define KZU_RESOURCE_PROFILING_TIMELINE_SEQUENCE_KZB |
Profiling tag for timeline sequence.
| #define KZU_RESOURCE_PROFILING_ANIMATION_CLIP_KZB |
Profiling tag for animation clip.
| #define KZU_RESOURCE_PROFILING_ANIMATION_KZB |
Profiling tag for animation.
| #define KZU_RESOURCE_PROFILING_COMPOSER_KZB |
Profiling tag for composer.
| #define KZU_RESOURCE_PROFILING_OBJECT_NODE_KZB |
Profiling tag for object node.
| #define KZU_RESOURCE_PROFILING_PREFAB_TEMPLATE_KZB |
Profiling tag for prefab template.
| #define KZU_RESOURCE_PROFILING_PREFAB_TEMPLATE_NODE_KZB |
Profiling tag for prefab template.
| #define KZU_RESOURCE_PROFILING_GENERIC_FILE_KZB |
Profiling tag for prefab template.
| #define KZU_RESOURCE_PROFILING_TRAJECTORY_KZB |
Profiling tag for trajectory.
| #define KZU_RESOURCE_PROFILING_OBJECT_SOURCE_KZB |
Profiling tag for object source.
| #define KZU_RESOURCE_PROFILING_FONT_KZB |
Profiling tag for font.
| #define KZU_RESOURCE_PROFILING_TEXT_KZB |
Profiling tag for text.
Resource loading strategy specifies when the resource is loaded and unloaded.
| Enumerator | |
|---|---|
| KZU_RESOURCE_LOADING_STRATEGY_DEFAULT |
When using the default strategy the engine loads the resource before it is needed. The loading strategy depends on the platform and Kanzi application, but the engine optimizes the loading strategy. |
| KZU_RESOURCE_LOADING_STRATEGY_MANUAL |
When using the manual loading strategy you must load and unload the resource manually by calling the kzuResourceLoad and kzuResourceUnload functions. This is the only loading strategy that you can control completely. |
| KZU_RESOURCE_LOADING_STRATEGY_OPTIMIZE_SPEED |
When using the optimize speed strategy the engine keeps the resource in RAM. When the application needs the resource, the engine can deploy the resource from RAM to GPU as fast as possible. The engine releases the resource from RAM only when the resource is not accessible anymore. This strategy guarantees that the engine does not unload the resource during runtime. |
| KZU_RESOURCE_LOADING_STRATEGY_OPTIMIZE_MEMORY |
When using the optimize memory loading strategy the engine unloads the resource as soon as possible. The engine releases the GPU resources from RAM after deploying the resources. |
| KZU_RESOURCE_LOADING_STRATEGY_ON_DEMAND |
When using the on demand strategy the engine loads the resource when it is needed and releases it when it is not needed anymore. On demand loading strategy differs from the optimize loading strategy in that it does not load the resource before it is needed. This strategy is not yet supported. |
| kzsError kzuResourceCreateKZBLoader | ( | const struct KzcMemoryManager * | memoryManager, |
| const struct KzuBinaryDirectory * | binaryDirectory, | ||
| kzString | path, | ||
| struct KzuResourceLoader ** | out_resourceLoader | ||
| ) |
Creates the resource loader that loads the resource from the project file (.KZB) using the given path.
| memoryManager | Memory manager to allocate memory for resource loader. |
| binaryDirectory | Binary directory containing resource to load. |
| path | Path of the resource inside a .KZB virtual file system. |
| out_resourceLoader | The created resource loader. |
| kzsError kzuResourceDelete | ( | struct KzuResource * | resource) |
Deletes the resource.
The reference count of the resource must be zero or an assert may fail.
After calling this function, the pointer to the resource becomes invalid and must not be used anymore.
| resource | The resource that will be deleted. |
| kzBool kzuResourceTypeIsTypeOf | ( | const KzuResourceType | resourceType, |
| const KzuResourceType | baseResourceType | ||
| ) |
Checks whether the resourceType, or one of its base types, is of the given base resource type.
| resourceType | The resource type to check. |
| baseResourceType | Resource type to check against. |
KZ_TRUE if the resource type or one of its parent types is of the given base resource type, otherwise returns KZ_FALSE. | kzBool kzuResourceIsTypeOf | ( | const struct KzuResource * | resource, |
| const KzuResourceType | resourceType | ||
| ) |
Checks whether the resource, or one of its base types, is of the given resource type.
| resource | The resource whose type to check. |
| resourceType | Resource type to check against. |
KZ_TRUE if the resource or one of its parent types is of the given resource type, otherwise returns KZ_FALSE. | KzuResourceType kzuResourceGetType | ( | const struct KzuResource * | resource) |
Returns the type of the resource.
| resource | The resource. |
| kzString kzuResourceTypeGetName | ( | KzuResourceType | resourceType) |
Returns the resource type name as a string.
This function is meant for debugging.
| resourceType | The resource type. |
| kzString kzuResourceGetName | ( | const struct KzuResource * | resource) |
Returns the name of the resource as a string.
| resource | The resource. |
| struct KzuResourceManager* kzuResourceGetResourceManager | ( | const struct KzuResource * | resource) |
Returns the resource manager that was used for creating the resource.
| resource | The resource. |
| kzsError kzuResourceLoad | ( | struct KzuResource * | resource) |
Loads the resource if the resource is not loaded.
Depending on the deployment strategy this may also deploy the resource if it is a GPU resource.
| resource | The resource to load. |
| kzsError kzuResourceUnload | ( | struct KzuResource * | resource) |
Unloads the resource if the resource is loaded.
Ignores the loading strategy.
| resource | The resource to unload. |
| kzBool kzuResourceIsLoaded | ( | const struct KzuResource * | resource) |
Checks whether the resource is loaded.
| resource | The resource. |
KZ_TRUE if the resource is loaded, otherwise returns KZ_FALSE. | enum KzuResourceLoadingStrategy kzuResourceGetLoadingStrategy | ( | const struct KzuResource * | resource) |
Returns the loading strategy of the resource.
| resource | The resource which loading strategy is returned. |
| void kzuResourceSetLoadingStrategy | ( | struct KzuResource * | resource, |
| enum KzuResourceLoadingStrategy | loadingStrategy | ||
| ) |
Sets the loading strategy of the resource.
| resource | The resource which loading strategy is set. |
| loadingStrategy | The loading strategy to use. See KzuResourceLoadingStrategy. |
| kzUint kzuResourceGetCPUMemoryUsage | ( | const struct KzuResource * | resource) |
Returns the amount of memory used by the resource.
| resource | The resource. |
| kzsError kzuResourceAcquire | ( | struct KzuResource * | resource) |
Acquires an existing resource, increasing the reference count by one.
| kzsError kzuResourceRelease | ( | struct KzuResource * | resource) |
Decreases the reference count of a resource by one, effectively releases the resource when the reference count reaches zero.
Note that the memory allocated for the resource may or may not be freed when the count reaches zero, depending on the resource manager's settings.
| resource | The resource which reference count to decrease. |
| kzsError kzuResourceLoad_private | ( | struct KzuResource * | resource, |
| const struct KzuResourceLoaderThreadContext * | threadContext | ||
| ) |
Private function for kzuResourceLoad() with specified thread context.
| kzsError kzuResourceFinishLoading_private | ( | struct KzuResource * | resource, |
| const struct KzuResourceLoaderThreadContext * | threadContext | ||
| ) |
Private function for finishing the loading of the resource.
| const KzuResourceType KZU_RESOURCE_TYPE_RESOURCE |
Base resource type identifier for all resources.
All resource types inherit from this resource type. This implies that kzuResourceIsTypeOf(resource, KZU_RESOURCE_TYPE_RESOURCE) always returns KZ_TRUE.