Skip to content

Commit

Permalink
Merge pull request #193 from rpavlik/missing-attributes
Browse files Browse the repository at this point in the history
Missing attributes
  • Loading branch information
rpavlik authored Sep 18, 2020
2 parents 10a2dea + 5f783b2 commit 63e7a59
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 32 deletions.
1 change: 1 addition & 0 deletions changes/sdk/pr.193.gh.OpenXR-SDK-Source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
layers: Fix ARM builds by re-adding function attributes.
9 changes: 5 additions & 4 deletions src/api_layers/api_dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,16 +404,17 @@ bool ApiDumpLayerRecordContent(std::vector<std::tuple<std::string, std::string,
return success;
}

XrResult ApiDumpLayerXrCreateInstance(const XrInstanceCreateInfo * /*info*/, XrInstance * /*instance*/) {
XRAPI_ATTR XrResult XRAPI_CALL ApiDumpLayerXrCreateInstance(const XrInstanceCreateInfo * /*info*/, XrInstance * /*instance*/) {
if (!g_record_info.initialized) {
g_record_info.initialized = true;
g_record_info.type = RECORD_TEXT_COUT;
}
return XR_SUCCESS;
}

XrResult ApiDumpLayerXrCreateApiLayerInstance(const XrInstanceCreateInfo *info, const struct XrApiLayerCreateInfo *apiLayerInfo,
XrInstance *instance) {
XRAPI_ATTR XrResult XRAPI_CALL ApiDumpLayerXrCreateApiLayerInstance(const XrInstanceCreateInfo *info,
const struct XrApiLayerCreateInfo *apiLayerInfo,
XrInstance *instance) {
try {
PFN_xrGetInstanceProcAddr next_get_instance_proc_addr = nullptr;
PFN_xrCreateApiLayerInstance next_create_api_layer_instance = nullptr;
Expand Down Expand Up @@ -548,7 +549,7 @@ XrResult ApiDumpLayerXrCreateApiLayerInstance(const XrInstanceCreateInfo *info,
}
}

XrResult ApiDumpLayerXrDestroyInstance(XrInstance instance) {
XRAPI_ATTR XrResult XRAPI_CALL ApiDumpLayerXrDestroyInstance(XrInstance instance) {
// Generate output for this command
std::vector<std::tuple<std::string, std::string, std::string>> contents;
contents.emplace_back("XrResult", "xrDestroyInstance", "");
Expand Down
30 changes: 18 additions & 12 deletions src/api_layers/core_validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ std::string StructTypesToString(GenValidUsageXrInstanceInfo *instance_info, cons
// "VUID-xrEnumerateInstanceExtensionProperties-propertyCountOutput-parameter"
// "VUID-xrEnumerateInstanceExtensionProperties-properties-parameter"

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

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

XrResult CoreValidationXrCreateApiLayerInstance(const XrInstanceCreateInfo *info, const struct XrApiLayerCreateInfo *apiLayerInfo,
XrInstance *instance) {
XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrCreateApiLayerInstance(const XrInstanceCreateInfo *info,
const struct XrApiLayerCreateInfo *apiLayerInfo,
XrInstance *instance) {
try {
XrApiLayerCreateInfo new_api_layer_info = {};
XrResult validation_result = XR_SUCCESS;
Expand Down Expand Up @@ -580,7 +581,7 @@ void EraseAllInstanceTableMapElements(GenValidUsageXrInstanceInfo *search_value)
map_erase_if(map, [=](value_t const &data) { return data.second.get() == search_value; });
}

XrResult CoreValidationXrDestroyInstance(XrInstance instance) {
XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrDestroyInstance(XrInstance instance) {
GenValidUsageInputsXrDestroyInstance(instance);
if (XR_NULL_HANDLE != instance) {
auto info_with_lock = g_instance_info.getWithLock(instance);
Expand All @@ -596,7 +597,8 @@ XrResult CoreValidationXrDestroyInstance(XrInstance instance) {
return result;
}

XrResult CoreValidationXrCreateSession(XrInstance instance, const XrSessionCreateInfo *createInfo, XrSession *session) {
XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrCreateSession(XrInstance instance, const XrSessionCreateInfo *createInfo,
XrSession *session) {
try {
XrResult test_result = GenValidUsageInputsXrCreateSession(instance, createInfo, session);
if (XR_SUCCESS != test_result) {
Expand Down Expand Up @@ -697,7 +699,8 @@ void CoreValidationDeleteSessionLabels(XrSession session) {
}

// ---- XR_EXT_debug_utils extension commands
XrResult CoreValidationXrSetDebugUtilsObjectNameEXT(XrInstance instance, const XrDebugUtilsObjectNameInfoEXT *nameInfo) {
XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrSetDebugUtilsObjectNameEXT(XrInstance instance,
const XrDebugUtilsObjectNameInfoEXT *nameInfo) {
try {
XrResult result = GenValidUsageInputsXrSetDebugUtilsObjectNameEXT(instance, nameInfo);
if (!XR_UNQUALIFIED_SUCCESS(result)) {
Expand All @@ -718,8 +721,9 @@ XrResult CoreValidationXrSetDebugUtilsObjectNameEXT(XrInstance instance, const X
}
}

XrResult CoreValidationXrCreateDebugUtilsMessengerEXT(XrInstance instance, const XrDebugUtilsMessengerCreateInfoEXT *createInfo,
XrDebugUtilsMessengerEXT *messenger) {
XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrCreateDebugUtilsMessengerEXT(XrInstance instance,
const XrDebugUtilsMessengerCreateInfoEXT *createInfo,
XrDebugUtilsMessengerEXT *messenger) {
try {
XrResult result = GenValidUsageInputsXrCreateDebugUtilsMessengerEXT(instance, createInfo, messenger);
if (!XR_UNQUALIFIED_SUCCESS(result)) {
Expand All @@ -745,7 +749,7 @@ XrResult CoreValidationXrCreateDebugUtilsMessengerEXT(XrInstance instance, const
}
}

XrResult CoreValidationXrDestroyDebugUtilsMessengerEXT(XrDebugUtilsMessengerEXT messenger) {
XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrDestroyDebugUtilsMessengerEXT(XrDebugUtilsMessengerEXT messenger) {
try {
XrResult result = GenValidUsageInputsXrDestroyDebugUtilsMessengerEXT(messenger);
if (!XR_UNQUALIFIED_SUCCESS(result)) {
Expand Down Expand Up @@ -773,7 +777,8 @@ XrResult CoreValidationXrDestroyDebugUtilsMessengerEXT(XrDebugUtilsMessengerEXT
}
}

XrResult CoreValidationXrSessionBeginDebugUtilsLabelRegionEXT(XrSession session, const XrDebugUtilsLabelEXT *labelInfo) {
XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrSessionBeginDebugUtilsLabelRegionEXT(XrSession session,
const XrDebugUtilsLabelEXT *labelInfo) {
XrResult test_result = GenValidUsageInputsXrSessionBeginDebugUtilsLabelRegionEXT(session, labelInfo);
if (XR_SUCCESS != test_result) {
return test_result;
Expand All @@ -788,7 +793,7 @@ XrResult CoreValidationXrSessionBeginDebugUtilsLabelRegionEXT(XrSession session,
return GenValidUsageNextXrSessionBeginDebugUtilsLabelRegionEXT(session, labelInfo);
}

XrResult CoreValidationXrSessionEndDebugUtilsLabelRegionEXT(XrSession session) {
XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrSessionEndDebugUtilsLabelRegionEXT(XrSession session) {
XrResult test_result = GenValidUsageInputsXrSessionEndDebugUtilsLabelRegionEXT(session);
if (XR_SUCCESS != test_result) {
return test_result;
Expand All @@ -803,7 +808,8 @@ XrResult CoreValidationXrSessionEndDebugUtilsLabelRegionEXT(XrSession session) {
return GenValidUsageNextXrSessionEndDebugUtilsLabelRegionEXT(session);
}

XrResult CoreValidationXrSessionInsertDebugUtilsLabelEXT(XrSession session, const XrDebugUtilsLabelEXT *labelInfo) {
XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrSessionInsertDebugUtilsLabelEXT(XrSession session,
const XrDebugUtilsLabelEXT *labelInfo) {
XrResult test_result = GenValidUsageInputsXrSessionInsertDebugUtilsLabelEXT(session, labelInfo);
if (XR_SUCCESS != test_result) {
return test_result;
Expand Down
9 changes: 4 additions & 5 deletions src/scripts/api_dump_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ def outputApiDumpExterns(self):
# self the ApiDumpOutputGenerator object
def outputLayerHeaderPrototypes(self):
generated_prototypes = '// Layer\'s xrGetInstanceProcAddr\n'
generated_prototypes += 'XrResult ApiDumpLayerXrGetInstanceProcAddr(XrInstance instance,\n'
generated_prototypes += 'XRAPI_ATTR XrResult XRAPI_CALL ApiDumpLayerXrGetInstanceProcAddr(XrInstance instance,\n'
generated_prototypes += ' const char* name, PFN_xrVoidFunction* function);\n\n'
generated_prototypes += '// Api Dump Log Command\n'
generated_prototypes += 'bool ApiDumpLayerRecordContent(std::vector<std::tuple<std::string, std::string, std::string>> contents);\n\n'
generated_prototypes += '// Api Dump Manual Functions\n'
generated_prototypes += 'XrInstance FindInstanceFromDispatchTable(XrGeneratedDispatchTable* dispatch_table);\n'
generated_prototypes += 'XrResult ApiDumpLayerXrCreateInstance(const XrInstanceCreateInfo *info,\n'
generated_prototypes += 'XRAPI_ATTR XrResult XRAPI_CALL ApiDumpLayerXrCreateInstance(const XrInstanceCreateInfo *info,\n'
generated_prototypes += ' XrInstance *instance);\n'
generated_prototypes += 'XrResult ApiDumpLayerXrDestroyInstance(XrInstance instance);\n'
generated_prototypes += 'XRAPI_ATTR XrResult XRAPI_CALL ApiDumpLayerXrDestroyInstance(XrInstance instance);\n'
generated_prototypes += '\n//Dump utility functions\n'
generated_prototypes += 'bool ApiDumpDecodeNextChain(XrGeneratedDispatchTable* gen_dispatch_table, const void* value, std::string prefix,\n'
generated_prototypes += ' std::vector<std::tuple<std::string, std::string, std::string>> &contents);\n'
Expand Down Expand Up @@ -1073,7 +1073,6 @@ def outputLayerCommands(self):
generated_commands += '#if %s\n' % cur_cmd.protect_string

prototype = cur_cmd.cdecl.replace(" xr", " ApiDumpLayerXr")
prototype = prototype.replace(self.genOpts.apicall, "").replace(self.genOpts.apientry, "")
prototype = prototype.replace(";", " {\n")
generated_commands += prototype

Expand Down Expand Up @@ -1181,7 +1180,7 @@ def outputLayerCommands(self):

# Output the xrGetInstanceProcAddr command for the API Dump layer.
generated_commands += '\n// Layer\'s xrGetInstanceProcAddr\n'
generated_commands += 'XrResult ApiDumpLayerXrGetInstanceProcAddr(\n'
generated_commands += 'XRAPI_ATTR XrResult XRAPI_CALL ApiDumpLayerXrGetInstanceProcAddr(\n'
generated_commands += ' XrInstance instance,\n'
generated_commands += ' const char* name,\n'
generated_commands += ' PFN_xrVoidFunction* function) {\n'
Expand Down
20 changes: 16 additions & 4 deletions src/scripts/src_genxr.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ def makeGenOpts(args):
defaultExtensions = 'openxr',
addExtensions = None,
removeExtensions = None,
emitExtensions = emitExtensionsPat)
emitExtensions = emitExtensionsPat,
apicall = 'XRAPI_ATTR ',
apientry = 'XRAPI_CALL ',
apientryp = 'XRAPI_PTR *')
]

genOpts['xr_generated_api_dump.hpp'] = [
Expand All @@ -287,7 +290,10 @@ def makeGenOpts(args):
defaultExtensions = 'openxr',
addExtensions = None,
removeExtensions = None,
emitExtensions = emitExtensionsPat)
emitExtensions = emitExtensionsPat,
apicall = 'XRAPI_ATTR ',
apientry = 'XRAPI_CALL ',
apientryp = 'XRAPI_PTR *')
]

# Source files generated for the core validation layer
Expand All @@ -304,7 +310,10 @@ def makeGenOpts(args):
defaultExtensions = 'openxr',
addExtensions = None,
removeExtensions = None,
emitExtensions = emitExtensionsPat)
emitExtensions = emitExtensionsPat,
apicall = 'XRAPI_ATTR ',
apientry = 'XRAPI_CALL ',
apientryp = 'XRAPI_PTR *')
]

genOpts['xr_generated_core_validation.cpp'] = [
Expand All @@ -320,7 +329,10 @@ def makeGenOpts(args):
defaultExtensions = 'openxr',
addExtensions = None,
removeExtensions = None,
emitExtensions = emitExtensionsPat)
emitExtensions = emitExtensionsPat,
apicall = 'XRAPI_ATTR ',
apientry = 'XRAPI_CALL ',
apientryp = 'XRAPI_PTR *')
]

# Generate a target based on the options in the matching genOpts{} object.
Expand Down
11 changes: 4 additions & 7 deletions src/scripts/validation_layer_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ def outputValidationHeaderInfo(self):
validation_header_info += '\n// ---- %s extension commands\n' % cur_cmd.ext_name
cur_extension_name = cur_cmd.ext_name

prototype = self.replace_ATTR_CALL(cur_cmd.cdecl)
prototype = cur_cmd.cdecl

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

def replace_ATTR_CALL(self, decl):
return decl.replace(self.genOpts.apicall, "").replace(self.genOpts.apientry, "")

# Generate C++ code to call down to the next layer/loader terminator/runtime
# self the ValidationSourceOutputGenerator object
# cur_command the command generated in automatic_source_generator.py to validate
Expand All @@ -2374,7 +2371,7 @@ def genNextValidateFunc(self, cur_command, has_return, is_create, is_destroy, is
# entry into the dispatch table so it's a special case all around.
if 'xrCreateInstance' in cur_command.name:
return ''
prototype = self.replace_ATTR_CALL(cur_command.cdecl.replace(" xr", " GenValidUsageNextXr"))
prototype = cur_command.cdecl.replace(" xr", " GenValidUsageNextXr")
prototype = prototype.replace(";", " {")
next_validate_func += '%s\n' % (prototype)
if has_return:
Expand Down Expand Up @@ -2517,7 +2514,7 @@ def genNextValidateFunc(self, cur_command, has_return, is_create, is_destroy, is
# has_return Boolean indicating that the command must return a value (usually XrResult)
def genAutoValidateFunc(self, cur_command, has_return):
auto_validate_func = ''
prototype = self.replace_ATTR_CALL(cur_command.cdecl.replace(" xr", " GenValidUsageXr"))
prototype = cur_command.cdecl.replace(" xr", " GenValidUsageXr")
prototype = prototype.replace(";", " {")
auto_validate_func += '%s\n' % (prototype)
auto_validate_func += self.writeIndent(1)
Expand Down Expand Up @@ -2677,7 +2674,7 @@ def outputValidationSourceFuncs(self):
validation_source_funcs += '\n'

validation_source_funcs += '\n// API Layer\'s xrGetInstanceProcAddr\n'
validation_source_funcs += 'XrResult GenValidUsageXrGetInstanceProcAddr(\n'
validation_source_funcs += 'XRAPI_ATTR XrResult XRAPI_CALL GenValidUsageXrGetInstanceProcAddr(\n'
validation_source_funcs += ' XrInstance instance,\n'
validation_source_funcs += ' const char* name,\n'
validation_source_funcs += ' PFN_xrVoidFunction* function) {\n'
Expand Down

0 comments on commit 63e7a59

Please sign in to comment.