Skip to content

Use clGetLayerInfo api_version to select layer init path#281

Open
joselopeqti wants to merge 2 commits into
KhronosGroup:mainfrom
joselopeqti:use_api_version_layer_init_path
Open

Use clGetLayerInfo api_version to select layer init path#281
joselopeqti wants to merge 2 commits into
KhronosGroup:mainfrom
joselopeqti:use_api_version_layer_init_path

Conversation

@joselopeqti

Copy link
Copy Markdown
Contributor

Currently the loader accepts only CL_LAYER_API_VERSION_100 layers and uses a single global flag (OCL_ICD_FORCE_LEGACY_TERMINATION) to switch between clInitLayer (v1.0) and clInitLayerWithProperties (v2.0). This
broke backward compatibility: layers built against ICD loader v1.0 could not be loaded by the v2.0 loader without an environment-variable override, which is unavailable in sandboxed environments such as Android apps.

This change uses the api_version returned by clGetLayerInfo(CL_LAYER_API_VERSION) to automatically select the correct initialization path per layer, without any user intervention:

CL_LAYER_API_VERSION_100 (100) — v1.0 layer
Uses clInitLayer. No clDeinitLayer is expected; the layer manages its own teardown via atexit().

CL_LAYER_API_VERSION_200 (200) — v2.0 layer [new constant]
Uses clInitLayerWithProperties. clDeinitLayer is optional.

Any other value — rejected with a descriptive trace message.

The dispatch call block now branches on which init function pointer was resolved (p_clInitLayer vs p_clInitLayerWithProperties) rather than on the global khrForceLegacyTermination flag.

khrForceLegacyTermination (OCL_ICD_FORCE_LEGACY_TERMINATION) is preserved as a last-resort escape hatch: when set it overrides the version-based path and treats all layers as v1.0, for exceptional cases where the layer's clGetLayerInfo reports an incorrect version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant