Skip to content

Commit e74f25f

Browse files
committed
loader: Permit broader valid usage re: layers.
1 parent 190e1e4 commit e74f25f

3 files changed

Lines changed: 26 additions & 37 deletions

File tree

src/loader/api_layer_interface.cpp

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -88,39 +88,32 @@ XrResult ApiLayerInterface::GetApiLayerProperties(const std::string& openxr_comm
8888
}
8989

9090
manifest_count = static_cast<uint32_t>(manifest_files.size());
91+
if (nullptr == outgoing_count) {
92+
LoaderLogger::LogErrorMessage("xrEnumerateInstanceExtensionProperties",
93+
"VUID-xrEnumerateApiLayerProperties-propertyCountOutput-parameter: null propertyCountOutput");
94+
return XR_ERROR_VALIDATION_FAILURE;
95+
}
96+
97+
*outgoing_count = manifest_count;
9198
if (0 == incoming_count) {
92-
if (nullptr == outgoing_count) {
93-
return XR_ERROR_VALIDATION_FAILURE;
94-
}
95-
*outgoing_count = manifest_count;
96-
} else if (nullptr != api_layer_properties) {
97-
if (incoming_count < manifest_count && nullptr != api_layer_properties) {
98-
LoaderLogger::LogErrorMessage(
99-
"xrEnumerateInstanceExtensionProperties",
100-
"VUID-xrEnumerateApiLayerProperties-propertyCapacityInput-parameter: insufficient space in array");
101-
*outgoing_count = manifest_count;
102-
return XR_ERROR_SIZE_INSUFFICIENT;
103-
}
99+
// capacity check only
100+
return XR_SUCCESS;
101+
}
102+
if (nullptr == api_layer_properties) {
103+
// incoming_count is not 0 BUT the api_layer_properties is NULL
104+
LoaderLogger::LogErrorMessage("xrEnumerateInstanceExtensionProperties",
105+
"VUID-xrEnumerateApiLayerProperties-properties-parameter: non-zero capacity but null array");
106+
return XR_ERROR_VALIDATION_FAILURE;
107+
}
108+
if (incoming_count < manifest_count) {
109+
LoaderLogger::LogErrorMessage(
110+
"xrEnumerateInstanceExtensionProperties",
111+
"VUID-xrEnumerateApiLayerProperties-propertyCapacityInput-parameter: insufficient space in array");
112+
return XR_ERROR_SIZE_INSUFFICIENT;
113+
}
104114

105-
uint32_t prop = 0;
106-
bool properties_valid = true;
107-
for (; prop < incoming_count && prop < manifest_count; ++prop) {
108-
if (nullptr != api_layer_properties[prop].next) {
109-
LoaderLogger::LogErrorMessage(openxr_command, "VUID-XrApiLayerProperties-next-next: expected NULL");
110-
properties_valid = false;
111-
}
112-
if (properties_valid) {
113-
api_layer_properties[prop] = manifest_files[prop]->GetApiLayerProperties();
114-
}
115-
}
116-
if (!properties_valid) {
117-
LoaderLogger::LogErrorMessage(openxr_command,
118-
"VUID-xrEnumerateApiLayerProperties-properties-parameter: invalid properties");
119-
return XR_ERROR_VALIDATION_FAILURE;
120-
}
121-
if (nullptr != outgoing_count) {
122-
*outgoing_count = prop;
123-
}
115+
for (uint32_t prop = 0; prop < incoming_count && prop < manifest_count; ++prop) {
116+
manifest_files[prop]->PopulateApiLayerProperties(api_layer_properties[prop]);
124117
}
125118
return XR_SUCCESS;
126119
}

src/loader/manifest_file.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -773,10 +773,7 @@ void ApiLayerManifestFile::CreateIfValid(ManifestFileType type, const std::strin
773773
manifest_files.back()->ParseCommon(layer_root_node);
774774
}
775775

776-
XrApiLayerProperties ApiLayerManifestFile::GetApiLayerProperties() const {
777-
XrApiLayerProperties props = {};
778-
props.type = XR_TYPE_API_LAYER_PROPERTIES;
779-
props.next = nullptr;
776+
void ApiLayerManifestFile::PopulateApiLayerProperties(XrApiLayerProperties &props) const {
780777
props.layerVersion = _implementation_version;
781778
props.specVersion = XR_MAKE_VERSION(_api_version.major, _api_version.minor, _api_version.patch);
782779
strncpy(props.layerName, _layer_name.c_str(), XR_MAX_API_LAYER_NAME_SIZE - 1);
@@ -787,7 +784,6 @@ XrApiLayerProperties ApiLayerManifestFile::GetApiLayerProperties() const {
787784
if (_description.size() >= XR_MAX_API_LAYER_DESCRIPTION_SIZE - 1) {
788785
props.description[XR_MAX_API_LAYER_DESCRIPTION_SIZE - 1] = '\0';
789786
}
790-
return props;
791787
}
792788

793789
// Find all layer manifest files in the appropriate search paths/registries for the given type.

src/loader/manifest_file.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class ApiLayerManifestFile : public ManifestFile {
9898
static XrResult FindManifestFiles(ManifestFileType type, std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files);
9999

100100
const std::string &LayerName() const { return _layer_name; }
101-
XrApiLayerProperties GetApiLayerProperties() const;
101+
void PopulateApiLayerProperties(XrApiLayerProperties &props) const;
102102

103103
private:
104104
ApiLayerManifestFile(ManifestFileType type, const std::string &filename, const std::string &layer_name,

0 commit comments

Comments
 (0)