Skip to content

Commit 63e7a59

Browse files
authored
Merge pull request #193 from rpavlik/missing-attributes
Missing attributes
2 parents 10a2dea + 5f783b2 commit 63e7a59

File tree

6 files changed

+48
-32
lines changed

6 files changed

+48
-32
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
layers: Fix ARM builds by re-adding function attributes.

src/api_layers/api_dump.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,16 +404,17 @@ bool ApiDumpLayerRecordContent(std::vector<std::tuple<std::string, std::string,
404404
return success;
405405
}
406406

407-
XrResult ApiDumpLayerXrCreateInstance(const XrInstanceCreateInfo * /*info*/, XrInstance * /*instance*/) {
407+
XRAPI_ATTR XrResult XRAPI_CALL ApiDumpLayerXrCreateInstance(const XrInstanceCreateInfo * /*info*/, XrInstance * /*instance*/) {
408408
if (!g_record_info.initialized) {
409409
g_record_info.initialized = true;
410410
g_record_info.type = RECORD_TEXT_COUT;
411411
}
412412
return XR_SUCCESS;
413413
}
414414

415-
XrResult ApiDumpLayerXrCreateApiLayerInstance(const XrInstanceCreateInfo *info, const struct XrApiLayerCreateInfo *apiLayerInfo,
416-
XrInstance *instance) {
415+
XRAPI_ATTR XrResult XRAPI_CALL ApiDumpLayerXrCreateApiLayerInstance(const XrInstanceCreateInfo *info,
416+
const struct XrApiLayerCreateInfo *apiLayerInfo,
417+
XrInstance *instance) {
417418
try {
418419
PFN_xrGetInstanceProcAddr next_get_instance_proc_addr = nullptr;
419420
PFN_xrCreateApiLayerInstance next_create_api_layer_instance = nullptr;
@@ -548,7 +549,7 @@ XrResult ApiDumpLayerXrCreateApiLayerInstance(const XrInstanceCreateInfo *info,
548549
}
549550
}
550551

551-
XrResult ApiDumpLayerXrDestroyInstance(XrInstance instance) {
552+
XRAPI_ATTR XrResult XRAPI_CALL ApiDumpLayerXrDestroyInstance(XrInstance instance) {
552553
// Generate output for this command
553554
std::vector<std::tuple<std::string, std::string, std::string>> contents;
554555
contents.emplace_back("XrResult", "xrDestroyInstance", "");

src/api_layers/core_validation.cpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ std::string StructTypesToString(GenValidUsageXrInstanceInfo *instance_info, cons
453453
// "VUID-xrEnumerateInstanceExtensionProperties-propertyCountOutput-parameter"
454454
// "VUID-xrEnumerateInstanceExtensionProperties-properties-parameter"
455455

456-
XrResult CoreValidationXrCreateInstance(const XrInstanceCreateInfo * /*info*/, XrInstance * /*instance*/) {
456+
XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrCreateInstance(const XrInstanceCreateInfo * /*info*/, XrInstance * /*instance*/) {
457457
// Shouldn't be called, coreValidationXrCreateApiLayerInstance should called instead
458458
return XR_SUCCESS;
459459
}
@@ -470,8 +470,9 @@ GenValidUsageXrInstanceInfo::~GenValidUsageXrInstanceInfo() { delete dispatch_ta
470470

471471
// See if there is a debug utils create structure in the "next" chain
472472

473-
XrResult CoreValidationXrCreateApiLayerInstance(const XrInstanceCreateInfo *info, const struct XrApiLayerCreateInfo *apiLayerInfo,
474-
XrInstance *instance) {
473+
XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrCreateApiLayerInstance(const XrInstanceCreateInfo *info,
474+
const struct XrApiLayerCreateInfo *apiLayerInfo,
475+
XrInstance *instance) {
475476
try {
476477
XrApiLayerCreateInfo new_api_layer_info = {};
477478
XrResult validation_result = XR_SUCCESS;
@@ -580,7 +581,7 @@ void EraseAllInstanceTableMapElements(GenValidUsageXrInstanceInfo *search_value)
580581
map_erase_if(map, [=](value_t const &data) { return data.second.get() == search_value; });
581582
}
582583

583-
XrResult CoreValidationXrDestroyInstance(XrInstance instance) {
584+
XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrDestroyInstance(XrInstance instance) {
584585
GenValidUsageInputsXrDestroyInstance(instance);
585586
if (XR_NULL_HANDLE != instance) {
586587
auto info_with_lock = g_instance_info.getWithLock(instance);
@@ -596,7 +597,8 @@ XrResult CoreValidationXrDestroyInstance(XrInstance instance) {
596597
return result;
597598
}
598599

599-
XrResult CoreValidationXrCreateSession(XrInstance instance, const XrSessionCreateInfo *createInfo, XrSession *session) {
600+
XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrCreateSession(XrInstance instance, const XrSessionCreateInfo *createInfo,
601+
XrSession *session) {
600602
try {
601603
XrResult test_result = GenValidUsageInputsXrCreateSession(instance, createInfo, session);
602604
if (XR_SUCCESS != test_result) {
@@ -697,7 +699,8 @@ void CoreValidationDeleteSessionLabels(XrSession session) {
697699
}
698700

699701
// ---- XR_EXT_debug_utils extension commands
700-
XrResult CoreValidationXrSetDebugUtilsObjectNameEXT(XrInstance instance, const XrDebugUtilsObjectNameInfoEXT *nameInfo) {
702+
XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrSetDebugUtilsObjectNameEXT(XrInstance instance,
703+
const XrDebugUtilsObjectNameInfoEXT *nameInfo) {
701704
try {
702705
XrResult result = GenValidUsageInputsXrSetDebugUtilsObjectNameEXT(instance, nameInfo);
703706
if (!XR_UNQUALIFIED_SUCCESS(result)) {
@@ -718,8 +721,9 @@ XrResult CoreValidationXrSetDebugUtilsObjectNameEXT(XrInstance instance, const X
718721
}
719722
}
720723

721-
XrResult CoreValidationXrCreateDebugUtilsMessengerEXT(XrInstance instance, const XrDebugUtilsMessengerCreateInfoEXT *createInfo,
722-
XrDebugUtilsMessengerEXT *messenger) {
724+
XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrCreateDebugUtilsMessengerEXT(XrInstance instance,
725+
const XrDebugUtilsMessengerCreateInfoEXT *createInfo,
726+
XrDebugUtilsMessengerEXT *messenger) {
723727
try {
724728
XrResult result = GenValidUsageInputsXrCreateDebugUtilsMessengerEXT(instance, createInfo, messenger);
725729
if (!XR_UNQUALIFIED_SUCCESS(result)) {
@@ -745,7 +749,7 @@ XrResult CoreValidationXrCreateDebugUtilsMessengerEXT(XrInstance instance, const
745749
}
746750
}
747751

748-
XrResult CoreValidationXrDestroyDebugUtilsMessengerEXT(XrDebugUtilsMessengerEXT messenger) {
752+
XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrDestroyDebugUtilsMessengerEXT(XrDebugUtilsMessengerEXT messenger) {
749753
try {
750754
XrResult result = GenValidUsageInputsXrDestroyDebugUtilsMessengerEXT(messenger);
751755
if (!XR_UNQUALIFIED_SUCCESS(result)) {
@@ -773,7 +777,8 @@ XrResult CoreValidationXrDestroyDebugUtilsMessengerEXT(XrDebugUtilsMessengerEXT
773777
}
774778
}
775779

776-
XrResult CoreValidationXrSessionBeginDebugUtilsLabelRegionEXT(XrSession session, const XrDebugUtilsLabelEXT *labelInfo) {
780+
XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrSessionBeginDebugUtilsLabelRegionEXT(XrSession session,
781+
const XrDebugUtilsLabelEXT *labelInfo) {
777782
XrResult test_result = GenValidUsageInputsXrSessionBeginDebugUtilsLabelRegionEXT(session, labelInfo);
778783
if (XR_SUCCESS != test_result) {
779784
return test_result;
@@ -788,7 +793,7 @@ XrResult CoreValidationXrSessionBeginDebugUtilsLabelRegionEXT(XrSession session,
788793
return GenValidUsageNextXrSessionBeginDebugUtilsLabelRegionEXT(session, labelInfo);
789794
}
790795

791-
XrResult CoreValidationXrSessionEndDebugUtilsLabelRegionEXT(XrSession session) {
796+
XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrSessionEndDebugUtilsLabelRegionEXT(XrSession session) {
792797
XrResult test_result = GenValidUsageInputsXrSessionEndDebugUtilsLabelRegionEXT(session);
793798
if (XR_SUCCESS != test_result) {
794799
return test_result;
@@ -803,7 +808,8 @@ XrResult CoreValidationXrSessionEndDebugUtilsLabelRegionEXT(XrSession session) {
803808
return GenValidUsageNextXrSessionEndDebugUtilsLabelRegionEXT(session);
804809
}
805810

806-
XrResult CoreValidationXrSessionInsertDebugUtilsLabelEXT(XrSession session, const XrDebugUtilsLabelEXT *labelInfo) {
811+
XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrSessionInsertDebugUtilsLabelEXT(XrSession session,
812+
const XrDebugUtilsLabelEXT *labelInfo) {
807813
XrResult test_result = GenValidUsageInputsXrSessionInsertDebugUtilsLabelEXT(session, labelInfo);
808814
if (XR_SUCCESS != test_result) {
809815
return test_result;

src/scripts/api_dump_generator.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ def outputApiDumpExterns(self):
119119
# self the ApiDumpOutputGenerator object
120120
def outputLayerHeaderPrototypes(self):
121121
generated_prototypes = '// Layer\'s xrGetInstanceProcAddr\n'
122-
generated_prototypes += 'XrResult ApiDumpLayerXrGetInstanceProcAddr(XrInstance instance,\n'
122+
generated_prototypes += 'XRAPI_ATTR XrResult XRAPI_CALL ApiDumpLayerXrGetInstanceProcAddr(XrInstance instance,\n'
123123
generated_prototypes += ' const char* name, PFN_xrVoidFunction* function);\n\n'
124124
generated_prototypes += '// Api Dump Log Command\n'
125125
generated_prototypes += 'bool ApiDumpLayerRecordContent(std::vector<std::tuple<std::string, std::string, std::string>> contents);\n\n'
126126
generated_prototypes += '// Api Dump Manual Functions\n'
127127
generated_prototypes += 'XrInstance FindInstanceFromDispatchTable(XrGeneratedDispatchTable* dispatch_table);\n'
128-
generated_prototypes += 'XrResult ApiDumpLayerXrCreateInstance(const XrInstanceCreateInfo *info,\n'
128+
generated_prototypes += 'XRAPI_ATTR XrResult XRAPI_CALL ApiDumpLayerXrCreateInstance(const XrInstanceCreateInfo *info,\n'
129129
generated_prototypes += ' XrInstance *instance);\n'
130-
generated_prototypes += 'XrResult ApiDumpLayerXrDestroyInstance(XrInstance instance);\n'
130+
generated_prototypes += 'XRAPI_ATTR XrResult XRAPI_CALL ApiDumpLayerXrDestroyInstance(XrInstance instance);\n'
131131
generated_prototypes += '\n//Dump utility functions\n'
132132
generated_prototypes += 'bool ApiDumpDecodeNextChain(XrGeneratedDispatchTable* gen_dispatch_table, const void* value, std::string prefix,\n'
133133
generated_prototypes += ' std::vector<std::tuple<std::string, std::string, std::string>> &contents);\n'
@@ -1073,7 +1073,6 @@ def outputLayerCommands(self):
10731073
generated_commands += '#if %s\n' % cur_cmd.protect_string
10741074

10751075
prototype = cur_cmd.cdecl.replace(" xr", " ApiDumpLayerXr")
1076-
prototype = prototype.replace(self.genOpts.apicall, "").replace(self.genOpts.apientry, "")
10771076
prototype = prototype.replace(";", " {\n")
10781077
generated_commands += prototype
10791078

@@ -1181,7 +1180,7 @@ def outputLayerCommands(self):
11811180

11821181
# Output the xrGetInstanceProcAddr command for the API Dump layer.
11831182
generated_commands += '\n// Layer\'s xrGetInstanceProcAddr\n'
1184-
generated_commands += 'XrResult ApiDumpLayerXrGetInstanceProcAddr(\n'
1183+
generated_commands += 'XRAPI_ATTR XrResult XRAPI_CALL ApiDumpLayerXrGetInstanceProcAddr(\n'
11851184
generated_commands += ' XrInstance instance,\n'
11861185
generated_commands += ' const char* name,\n'
11871186
generated_commands += ' PFN_xrVoidFunction* function) {\n'

src/scripts/src_genxr.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,10 @@ def makeGenOpts(args):
271271
defaultExtensions = 'openxr',
272272
addExtensions = None,
273273
removeExtensions = None,
274-
emitExtensions = emitExtensionsPat)
274+
emitExtensions = emitExtensionsPat,
275+
apicall = 'XRAPI_ATTR ',
276+
apientry = 'XRAPI_CALL ',
277+
apientryp = 'XRAPI_PTR *')
275278
]
276279

277280
genOpts['xr_generated_api_dump.hpp'] = [
@@ -287,7 +290,10 @@ def makeGenOpts(args):
287290
defaultExtensions = 'openxr',
288291
addExtensions = None,
289292
removeExtensions = None,
290-
emitExtensions = emitExtensionsPat)
293+
emitExtensions = emitExtensionsPat,
294+
apicall = 'XRAPI_ATTR ',
295+
apientry = 'XRAPI_CALL ',
296+
apientryp = 'XRAPI_PTR *')
291297
]
292298

293299
# Source files generated for the core validation layer
@@ -304,7 +310,10 @@ def makeGenOpts(args):
304310
defaultExtensions = 'openxr',
305311
addExtensions = None,
306312
removeExtensions = None,
307-
emitExtensions = emitExtensionsPat)
313+
emitExtensions = emitExtensionsPat,
314+
apicall = 'XRAPI_ATTR ',
315+
apientry = 'XRAPI_CALL ',
316+
apientryp = 'XRAPI_PTR *')
308317
]
309318

310319
genOpts['xr_generated_core_validation.cpp'] = [
@@ -320,7 +329,10 @@ def makeGenOpts(args):
320329
defaultExtensions = 'openxr',
321330
addExtensions = None,
322331
removeExtensions = None,
323-
emitExtensions = emitExtensionsPat)
332+
emitExtensions = emitExtensionsPat,
333+
apicall = 'XRAPI_ATTR ',
334+
apientry = 'XRAPI_CALL ',
335+
apientryp = 'XRAPI_PTR *')
324336
]
325337

326338
# Generate a target based on the options in the matching genOpts{} object.

src/scripts/validation_layer_generator.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ def outputValidationHeaderInfo(self):
553553
validation_header_info += '\n// ---- %s extension commands\n' % cur_cmd.ext_name
554554
cur_extension_name = cur_cmd.ext_name
555555

556-
prototype = self.replace_ATTR_CALL(cur_cmd.cdecl)
556+
prototype = cur_cmd.cdecl
557557

558558
# We need to always export xrGetInstanceProcAddr, even though we automatically generate it.
559559
# Also, we really only need the core function, not the others.
@@ -2357,9 +2357,6 @@ def genValidateInputsFunc(self, cur_command):
23572357
pre_validate_func += '}\n\n'
23582358
return pre_validate_func
23592359

2360-
def replace_ATTR_CALL(self, decl):
2361-
return decl.replace(self.genOpts.apicall, "").replace(self.genOpts.apientry, "")
2362-
23632360
# Generate C++ code to call down to the next layer/loader terminator/runtime
23642361
# self the ValidationSourceOutputGenerator object
23652362
# cur_command the command generated in automatic_source_generator.py to validate
@@ -2374,7 +2371,7 @@ def genNextValidateFunc(self, cur_command, has_return, is_create, is_destroy, is
23742371
# entry into the dispatch table so it's a special case all around.
23752372
if 'xrCreateInstance' in cur_command.name:
23762373
return ''
2377-
prototype = self.replace_ATTR_CALL(cur_command.cdecl.replace(" xr", " GenValidUsageNextXr"))
2374+
prototype = cur_command.cdecl.replace(" xr", " GenValidUsageNextXr")
23782375
prototype = prototype.replace(";", " {")
23792376
next_validate_func += '%s\n' % (prototype)
23802377
if has_return:
@@ -2517,7 +2514,7 @@ def genNextValidateFunc(self, cur_command, has_return, is_create, is_destroy, is
25172514
# has_return Boolean indicating that the command must return a value (usually XrResult)
25182515
def genAutoValidateFunc(self, cur_command, has_return):
25192516
auto_validate_func = ''
2520-
prototype = self.replace_ATTR_CALL(cur_command.cdecl.replace(" xr", " GenValidUsageXr"))
2517+
prototype = cur_command.cdecl.replace(" xr", " GenValidUsageXr")
25212518
prototype = prototype.replace(";", " {")
25222519
auto_validate_func += '%s\n' % (prototype)
25232520
auto_validate_func += self.writeIndent(1)
@@ -2677,7 +2674,7 @@ def outputValidationSourceFuncs(self):
26772674
validation_source_funcs += '\n'
26782675

26792676
validation_source_funcs += '\n// API Layer\'s xrGetInstanceProcAddr\n'
2680-
validation_source_funcs += 'XrResult GenValidUsageXrGetInstanceProcAddr(\n'
2677+
validation_source_funcs += 'XRAPI_ATTR XrResult XRAPI_CALL GenValidUsageXrGetInstanceProcAddr(\n'
26812678
validation_source_funcs += ' XrInstance instance,\n'
26822679
validation_source_funcs += ' const char* name,\n'
26832680
validation_source_funcs += ' PFN_xrVoidFunction* function) {\n'

0 commit comments

Comments
 (0)