diff --git a/include/ur.py b/include/ur.py index ec42418a4f..5597773501 100644 --- a/include/ur.py +++ b/include/ur.py @@ -2264,53 +2264,6 @@ def __str__(self): ############################################################################### __use_win_types = "Windows" == platform.uname()[0] -############################################################################### -## @brief Function-pointer for urLoaderConfigCreate -if __use_win_types: - _urLoaderConfigCreate_t = WINFUNCTYPE( ur_result_t, POINTER(ur_loader_config_handle_t) ) -else: - _urLoaderConfigCreate_t = CFUNCTYPE( ur_result_t, POINTER(ur_loader_config_handle_t) ) - -############################################################################### -## @brief Function-pointer for urLoaderConfigRetain -if __use_win_types: - _urLoaderConfigRetain_t = WINFUNCTYPE( ur_result_t, ur_loader_config_handle_t ) -else: - _urLoaderConfigRetain_t = CFUNCTYPE( ur_result_t, ur_loader_config_handle_t ) - -############################################################################### -## @brief Function-pointer for urLoaderConfigRelease -if __use_win_types: - _urLoaderConfigRelease_t = WINFUNCTYPE( ur_result_t, ur_loader_config_handle_t ) -else: - _urLoaderConfigRelease_t = CFUNCTYPE( ur_result_t, ur_loader_config_handle_t ) - -############################################################################### -## @brief Function-pointer for urLoaderConfigGetInfo -if __use_win_types: - _urLoaderConfigGetInfo_t = WINFUNCTYPE( ur_result_t, ur_loader_config_handle_t, ur_loader_config_info_t, c_size_t, c_void_p, POINTER(c_size_t) ) -else: - _urLoaderConfigGetInfo_t = CFUNCTYPE( ur_result_t, ur_loader_config_handle_t, ur_loader_config_info_t, c_size_t, c_void_p, POINTER(c_size_t) ) - -############################################################################### -## @brief Function-pointer for urLoaderConfigEnableLayer -if __use_win_types: - _urLoaderConfigEnableLayer_t = WINFUNCTYPE( ur_result_t, ur_loader_config_handle_t, c_char_p ) -else: - _urLoaderConfigEnableLayer_t = CFUNCTYPE( ur_result_t, ur_loader_config_handle_t, c_char_p ) - - -############################################################################### -## @brief Table of LoaderConfig functions pointers -class ur_loader_config_dditable_t(Structure): - _fields_ = [ - ("pfnCreate", c_void_p), ## _urLoaderConfigCreate_t - ("pfnRetain", c_void_p), ## _urLoaderConfigRetain_t - ("pfnRelease", c_void_p), ## _urLoaderConfigRelease_t - ("pfnGetInfo", c_void_p), ## _urLoaderConfigGetInfo_t - ("pfnEnableLayer", c_void_p) ## _urLoaderConfigEnableLayer_t - ] - ############################################################################### ## @brief Function-pointer for urPlatformGet if __use_win_types: @@ -3792,7 +3745,6 @@ class ur_device_dditable_t(Structure): ############################################################################### class ur_dditable_t(Structure): _fields_ = [ - ("LoaderConfig", ur_loader_config_dditable_t), ("Platform", ur_platform_dditable_t), ("Context", ur_context_dditable_t), ("Event", ur_event_dditable_t), diff --git a/scripts/YaML.md b/scripts/YaML.md index a735a7f7a4..3794020bb7 100644 --- a/scripts/YaML.md +++ b/scripts/YaML.md @@ -599,12 +599,14 @@ class ur_name_t(Structure): * A function requires the following scalar fields: {`desc`, `name`} - `desc` will be used as the function's description comment - `name` must be a unique ISO-C standard identifier, and be PascalCase -* A function may take the following optional scalar fields: {`class`, `decl`, `condition`, `ordinal`, `version`} +* A function may take the following optional scalar fields: {`class`, `decl`, `condition`, `ordinal`, `version`, `loader_only`} - `class` will be used to scope the function declaration within the specified C++ class - `decl` will be used to specify the function's linkage as one of the following: {`static`} - `condition` will be used as a C/C++ preprocessor `#if` conditional expression - `ordinal` will be used to override the default order (in which they appear) the function appears within its section; `default="1000"` - `version` will be used to define the minimum API version in which the function will appear; `default="1.0"` This will also affect the order in which the function appears within its section and class. + - `loader_only` will be used to decide whether the function will only be implemented by the loader and not appear in the adapters + interface. * A function requires the following sequence of mappings: {`params`} - A param requires the following scalar fields: {`desc`, `type`, `name`} + `desc` will be used as the params's description comment diff --git a/scripts/core/runtime.yml b/scripts/core/runtime.yml index 06010a643c..c14f939cc2 100644 --- a/scripts/core/runtime.yml +++ b/scripts/core/runtime.yml @@ -31,6 +31,7 @@ etors: type: function desc: "Create a loader config object." class: $xLoaderConfig +loader_only: True name: Create decl: static params: @@ -41,6 +42,7 @@ params: type: function desc: "Get a reference to the loader config object." class: $xLoaderConfig +loader_only: True name: Retain decl: static details: @@ -55,6 +57,7 @@ params: type: function desc: "Release config handle." class: $xLoaderConfig +loader_only: True name: Release decl: static details: @@ -80,6 +83,7 @@ etors: type: function desc: "Retrieves various information about the loader." class: $xLoaderConfig +loader_only: True name: GetInfo decl: static details: @@ -122,6 +126,7 @@ returns: type: function desc: "Enable a layer for the specified loader config." class: $xLoaderConfig +loader_only: True name: EnableLayer decl: static params: diff --git a/scripts/templates/api.py.mako b/scripts/templates/api.py.mako index 0399bf1ba8..35a2fd6d27 100644 --- a/scripts/templates/api.py.mako +++ b/scripts/templates/api.py.mako @@ -178,9 +178,6 @@ class ${N}_DDI: self.__dll.${x}Init(0, 0) %for tbl in tables: - %if 'Loader' in tbl['name']: -<% continue %> - %endif # call driver to get function pointers ${tbl['name']} = ${tbl['type']}() r = ${x}_result_v(self.__dll.${tbl['export']['name']}(version, byref(${tbl['name']}))) diff --git a/scripts/templates/ddi.h.mako b/scripts/templates/ddi.h.mako index 26d7f3f93d..3a0e0c1af2 100644 --- a/scripts/templates/ddi.h.mako +++ b/scripts/templates/ddi.h.mako @@ -31,9 +31,6 @@ extern "C" { #endif %for tbl in th.get_pfntables(specs, meta, n, tags): -%if 'Loader' in tbl['export']['name']: - <% continue %> -%endif %for obj in tbl['functions']: /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for ${th.make_func_name(n, tags, obj)} @@ -97,9 +94,6 @@ typedef ${x}_result_t (${X}_APICALL *${tbl['pfn']})( typedef struct ${n}_dditable_t { %for tbl in th.get_pfntables(specs, meta, n, tags): -%if 'loader' in tbl['type']: - <% continue %> -%endif ${th.append_ws(tbl['type'], 35)} ${tbl['name']}; %endfor } ${n}_dditable_t; diff --git a/scripts/templates/helper.py b/scripts/templates/helper.py index 1e738dbc09..d1a60a7b2d 100644 --- a/scripts/templates/helper.py +++ b/scripts/templates/helper.py @@ -440,6 +440,14 @@ def is_global(item, tags): except: return False + @staticmethod + def is_loader_only(item): + try: + return item['loader_only'] + except: + return False + + """ Public: substitutes each tag['key'] with tag['value'] @@ -1047,6 +1055,9 @@ def get_pfntables(specs, meta, namespace, tags): tables = [] for cname in sorted(meta['class'], key=lambda x: meta['class'][x]['ordinal']): objs, exp_objs = get_class_function_objs_exp(specs, cname) + objs = list(filter(lambda obj: not function_traits.is_loader_only(obj), objs)) + exp_objs = list(filter(lambda obj: not function_traits.is_loader_only(obj), exp_objs)) + if len(objs) > 0: name = get_table_name(namespace, tags, objs[0]) table = "%s_%s_dditable_t"%(namespace, _camel_to_snake(name)) @@ -1111,6 +1122,7 @@ def get_pfntables(specs, meta, namespace, tags): return tables + """ Private: returns the list of parameters, filtering based on desc tags diff --git a/scripts/templates/libapi.cpp.mako b/scripts/templates/libapi.cpp.mako index c2fb67808e..cf713fd226 100644 --- a/scripts/templates/libapi.cpp.mako +++ b/scripts/templates/libapi.cpp.mako @@ -56,7 +56,7 @@ ${th.make_func_name(n, tags, obj)}( %endfor ) try { -%if 'Loader' in obj['class']: +%if th.function_traits.is_loader_only(obj): return ur_lib::${th.make_func_name(n, tags, obj)}(${", ".join(th.make_param_lines(n, tags, obj, format=["name"]))} ); %else: %if re.match("Init", obj['name']): diff --git a/scripts/templates/libddi.cpp.mako b/scripts/templates/libddi.cpp.mako index fc04c20ff8..de73cc2fc7 100644 --- a/scripts/templates/libddi.cpp.mako +++ b/scripts/templates/libddi.cpp.mako @@ -33,9 +33,6 @@ namespace ${x}_lib ${x}_result_t result = ${X}_RESULT_SUCCESS; %for tbl in th.get_pfntables(specs, meta, n, tags): - %if 'Loader' in tbl['export']['name']: - <% continue %> - %endif if( ${X}_RESULT_SUCCESS == result ) { result = ${tbl['export']['name']}( ${X}_API_VERSION_CURRENT, &${n}DdiTable.${tbl['name']} );