Skip to content

Instantly share code, notes, and snippets.

@fredemmott
Last active October 4, 2023 16:39
Show Gist options
  • Save fredemmott/11ed2f4cb37d3788025603435ddd12b2 to your computer and use it in GitHub Desktop.
Save fredemmott/11ed2f4cb37d3788025603435ddd12b2 to your computer and use it in GitHub Desktop.
XrResult OXRTracing_xrEnumerateInstanceExtensionProperties(
const char* layerName, uint32_t propertyCapacityInput,
uint32_t* propertyCountOutput, XrExtensionProperties* properties)
{
TraceLoggingActivity<gTraceProvider> localActivity;
TraceLoggingWriteStart(localActivity,
"xrEnumerateInstanceExtensionProperties",
TraceLoggingString(layerName, "layerName"),
TraceLoggingUInt32(propertyCapacityInput, "propertyCapacityInput"));
// The OpenXR specification says that this should work without an instance,
// however, a 'next' pointer is needed to query extensions that might be
// provided by another API layer, and the OpenXR *Loader* spec says:
//
// "an implicit API layer, it must add it’s own instance extension
// contents to the list of extensions."; this means we - and any lower
// layers - need the 'next' pointer, which can vary by instance
if (layerName == NULL && gXrNextEnumerateInstanceExtensionProperties) {
const auto ret = gXrNextEnumerateInstanceExtensionProperties(
layerName, propertyCapacityInput, propertyCountOutput, properties);
if (XR_SUCCEEDED(ret)) {
const auto propertyCount
= std::min(propertyCapacityInput, *propertyCountOutput);
for (auto i = 0; i < propertyCount; ++i) {
OXRTL_DUMP_XrExtensionProperties(localActivity,
"xrEnumerateInstanceExtensionProperties", "properties[]",
(properties[i]));
}
}
TraceLoggingWriteStop(localActivity,
"xrEnumerateInstanceExtensionProperties",
TraceLoggingUInt32(*propertyCountOutput, "propertyCountOutput"),
OXRTL_ARGS_XrResult(ret, "XrResult"));
return ret;
}
*propertyCountOutput = 0;
TraceLoggingWriteStop(localActivity,
"xrEnumerateInstanceExtensionProperties",
TraceLoggingUInt32(0, "propertyCountOutput"),
OXRTL_ARGS_XrResult(XR_SUCCESS, "XrResult"));
return XR_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment