Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update OpenXR-SDK to 1.0.29 #139

Merged
merged 7 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 48 additions & 15 deletions generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ impl Parser {
extensions: IndexMap::new(),
// TODO: Handle these extensions
disabled_exts: [
"XR_HTC_passthrough",
"XR_MSFT_scene_understanding",
"XR_MSFT_scene_understanding_serialization",
]
Expand Down Expand Up @@ -312,16 +313,16 @@ impl Parser {
if attr(attrs, "supported").map_or(false, |x| x == "disabled") {
self.disabled_exts.insert(ext_name);
} else {
let (tag, _) = split_ext_tag(&ext_name);
self.extensions
.get_mut(tag)
.unwrap()
.extensions
.push(Extension {
let (tag_name, _) = split_ext_tag(&ext_name);
if let Some(tag) = self.extensions.get_mut(tag_name) {
tag.extensions.push(Extension {
name: ext_name,
version: ext_version.unwrap(),
commands,
});
} else {
eprintln!("ignoring extension with unlisted tag: {}", ext_name);
}
}
}

Expand Down Expand Up @@ -546,6 +547,11 @@ impl Parser {
}

fn parse_struct(&mut self, attrs: &[OwnedAttribute]) {
const STRUCTS_BLACKLIST: [&str; 3] = [
"XrCompositionLayerPassthroughHTC",
"XrPassthroughColorHTC",
"XrPassthroughHTC",
];
Ralith marked this conversation as resolved.
Show resolved Hide resolved
let struct_name = attr(attrs, "name").unwrap();
let mut members = Vec::new();
let mut ty = None;
Expand Down Expand Up @@ -579,11 +585,22 @@ impl Parser {
_ => {}
}
}
let parent: Option<String> = attr(attrs, "parentstruct").map(|x| x.into());
if let Some(ref parent) = parent {
if STRUCTS_BLACKLIST.contains(&struct_name) {
return;
}
if let Some(structextends) = attr(attrs, "structextends") {
if STRUCTS_BLACKLIST.contains(&structextends) {
return;
}
}
let parent = attr(attrs, "parentstruct");
if let Some(parent) = parent {
if STRUCTS_BLACKLIST.contains(&parent) {
return;
}
self.base_headers
.entry(parent.clone())
.or_insert_with(Vec::new)
.entry(parent.into())
.or_default()
.push(struct_name.into());
}
if let Some(target) = attr(attrs, "alias") {
Expand Down Expand Up @@ -1098,6 +1115,8 @@ impl Parser {
quote! { #[derive(Copy, Clone)] }
} else if meta.has_pointer || meta.has_array {
quote! { #[derive(Copy, Clone, Debug)] }
} else if meta.has_non_default {
quote! { #[derive(Copy, Clone, Debug, PartialEq)] }
} else {
quote! { #[derive(Copy, Clone, Debug, Default, PartialEq)] }
};
Expand All @@ -1116,7 +1135,7 @@ impl Parser {
let commands = self.commands.iter().chain(
self.cmd_aliases
.iter()
.map(|&(ref name, ref target)| (name, self.commands.get(target).unwrap())),
.map(|(name, target)| (name, self.commands.get(target).unwrap())),
);

let (pfns, protos) = commands
Expand Down Expand Up @@ -1214,6 +1233,7 @@ impl Parser {
/// Function pointer prototypes
pub mod pfn {
use super::*;
pub use crate::platform::EglGetProcAddressMNDX;

pub type VoidFunction = unsafe extern "system" fn();
pub type DebugUtilsMessengerCallbackEXT = unsafe extern "system" fn(
Expand Down Expand Up @@ -1601,10 +1621,14 @@ impl Parser {
out.has_pointer |= member.ptr_depth != 0 || self.handles.contains(&member.ty);
out.has_graphics |= member.ty == "XrSession" || member.ty == "XrSwapchain";
out.has_array |= member.static_array_len.is_some();
out.has_non_default |= member.ty == "XrTime";
if member.ty != name {
if let Some(x) = self.structs.get(&member.ty) {
out |= self.compute_meta(&member.ty, x);
}
if self.enums.contains_key(&member.ty) {
out.has_non_default = true;
}
}
}
out
Expand Down Expand Up @@ -1780,10 +1804,17 @@ impl Parser {
let mut inner = m.clone();
inner.ptr_depth -= 1;
let ty = xr_var_ty(self.api_aliases.as_ref(), &inner);
(
quote! { &'a #ty #type_args },
quote! { self.inner.#ident = value as *const _ as _; },
)
if m.is_const {
(
quote! { &'a #ty #type_args },
quote! { self.inner.#ident = value as *const _ as _; },
)
} else {
(
quote! { &'a mut #ty #type_args },
quote! { self.inner.#ident = value as *mut _ as _; },
)
}
} else if self.structs.contains_key(&m.ty) && !simple.contains(&m.ty[..]) {
let ty = xr_var_ty(self.api_aliases.as_ref(), m);
(
Expand Down Expand Up @@ -1984,6 +2015,7 @@ struct StructMeta {
has_pointer: bool,
has_array: bool,
has_graphics: bool,
has_non_default: bool,
}

impl StructMeta {
Expand Down Expand Up @@ -2026,6 +2058,7 @@ impl std::ops::BitOrAssign for StructMeta {
self.has_pointer |= rhs.has_pointer;
self.has_array |= rhs.has_array;
self.has_graphics |= rhs.has_graphics;
self.has_non_default |= self.has_non_default;
}
}

Expand Down
Loading