OpenXR SDK 1.1.57 compatibility#55
Conversation
…3, because API LAYER functions has been moved from external include file to the XR Registry
…string which size is not defined in an enum
…positionLayerPassthroughFB); this fix keeps the parent's name and so the derivated structure affected member does not follow the registry name.
|
Compile without error using the OpenXR-SDK 1.1.51 (thanks to the previous fix). |
…n structure contains an application managed pointer member
… parameter in function call
|
Hi, Thanks for working on fixing these compatibility problems! I'm trying out this fork with SDK 1.1.57, and I've come across a couple of issues.
I'm pretty sure this happens because under the Microsoft ABI a derived class cannot reuse a non-empty base's padding.
|
|
about : I totaly missed the templated functions and remove the parameter and code in a previous patch. So I reworked this point and add an auto-detect feature, and for now two functions are templated with the two_call idiom (enumerateSwapchainImagesToVector, enumerateEnvironmentDepthSwapchainImagesToVectorMETA). Let me know if this fix your first point. |
|
about : As you saw, my patches replace some C type with C++ type (previously defined but not projected), but it also replace pointer with reference (to avoid null pointer, and write more "natural/modern" code). I also add a list of native C type to project (uint32_t...) and so these pointer are replaced also by reference. This is to follow "modern C++" concept, and so this cause compatibility issue. However, you can easily revert to the previous mode by modifing the OpenXR-Hpp/scripts/data.py file as follow : Let me know if this fix your compatibility issue |
|
About : It seems you're right, the Future base struct include a simple 32 bits Result data member, but the struct size is 16 bytes aligned and so the compiler add 8 bytes padding, which causes, under Winkdows ABI, the derivated classes to have a larger size. I'm developping under Linux and I don't have a valid Windows environment yet to check and test or modify this point. I will see later. Regards |
|
|
I defined a specific projection for the XrFutureCompletionBaseHeaderEXT, that take care of the Windows 64bits ABI. Let me know if this fix works on Windows 64bits. Regards |
|
I had to change a few things to get it working:
I didn't add I've also checked the Here's the diff: diff --git a/scripts/cpp_generator.py b/scripts/cpp_generator.py
index 8bdec4f..d9a11d9 100644
--- a/scripts/cpp_generator.py
+++ b/scripts/cpp_generator.py
@@ -218,6 +218,12 @@ class StructProjection:
return "next_"
return None
+ @property
+ def alignas_spec(self):
+ if self.parent_type == "XrFutureCompletionBaseHeaderEXT":
+ return "\n#ifdef _WIN64\nalignas(void*)\n#endif\n"
+ return ""
+
DISPATCH_TEMPLATE_PARAM_NAME = "Dispatch"
DISPATCH_TEMPLATE_DEFN = f"typename {DISPATCH_TEMPLATE_PARAM_NAME}"
diff --git a/scripts/data.py b/scripts/data.py
index 85d45d9..3ab1561 100644
--- a/scripts/data.py
+++ b/scripts/data.py
@@ -32,6 +32,7 @@ MANUALLY_PROJECTED_SCALARS = set((
MANUALLY_PROJECTED = set((
"XrEventDataBuffer",
+ "XrFutureCompletionBaseHeaderEXT",
)).union(MANUALLY_PROJECTED_SCALARS)
PROJECTED_NATIVE_C_TYPE = set((
@@ -48,7 +49,6 @@ PROJECTED_NATIVE_C_TYPE = set((
SKIP_PROJECTION = set((
"XrBaseInStructure",
"XrBaseOutStructure",
- "XrSpatialAnchorCreateCompletionBD",
))
UPPER_TOKENS = set((
diff --git a/scripts/struct.hpp b/scripts/struct.hpp
index 2c6d6b2..fb8c4e4 100644
--- a/scripts/struct.hpp
+++ b/scripts/struct.hpp
@@ -115,7 +115,7 @@
//! @ingroup structs
//# endif
//# endfilter
- struct XR_MAY_ALIAS /*{ s.cpp_name }*/ /*{ s.struct_parent_decl }*/
+ struct XR_MAY_ALIAS /*{ s.alignas_spec }*/ /*{ s.cpp_name }*/ /*{ s.struct_parent_decl }*/
{
//# if s.typed_struct
private:
diff --git a/scripts/template_openxr_structs.hpp b/scripts/template_openxr_structs.hpp
index 91a4c77..6cfef86 100644
--- a/scripts/template_openxr_structs.hpp
+++ b/scripts/template_openxr_structs.hpp
@@ -103,30 +103,46 @@ namespace impl {
void* next;
};
/*{ wrapperSizeStaticAssert('::XrBaseOutStructure', 'OutputStructBase') }*/
-
- #ifdef _WIN64
- #pragma pack(push, 4)
- #endif
-
- class XR_MAY_ALIAS FutureCompletionBaseHeaderEXT : public InputStructBase {
- protected:
- FutureCompletionBaseHeaderEXT(StructureType type_, void *next_) : InputStructBase(type_, next_) {}
-
- public:
- XrResult futureResult;
- };
-
- #ifdef _WIN64
- #pragma pack(pop)
- #endif
-
- #ifdef _WIN64
- static_assert(sizeof(FutureCompletionBaseHeaderEXT) == 20);
- #else
- static_assert(sizeof(FutureCompletionBaseHeaderEXT) == 24);
- #endif
} // namespace impl
+#ifdef XR_EXT_future
+#ifdef _WIN64
+ #pragma pack(push, 4)
+#endif
+/*!
+ * C++ projection of XrFutureCompletionBaseHeaderEXT
+ *
+ * Provided by the `XR_EXT_future` extension.
+ *
+ * @see
+ * <https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XrFutureCompletionBaseHeaderEXT>
+ * @xrentity{XrFutureCompletionBaseHeaderEXT}
+ * @ingroup abstracttypedstructs
+ */
+class XR_MAY_ALIAS FutureCompletionBaseHeaderEXT : public impl::OutputStructBase {
+private:
+ using Parent = impl::OutputStructBase;
+
+protected:
+ //! Protected constructor: this type is abstract.
+ FutureCompletionBaseHeaderEXT(StructureType type_, const Result& futureResult_,
+ void* next_ = nullptr)
+ : Parent(type_, next_), futureResult{futureResult_} {}
+
+public:
+ Result futureResult;
+};
+#ifdef _WIN64
+ #pragma pack(pop)
+#endif
+
+#ifdef _WIN64
+ static_assert(sizeof(FutureCompletionBaseHeaderEXT) == 20);
+#else
+ /*{ wrapperSizeStaticAssert('::XrFutureCompletionBaseHeaderEXT', 'FutureCompletionBaseHeaderEXT') }*/
+#endif
+#endif // XR_EXT_future
+
//# filter block_doxygen_comment
//! @brief Wrapper for XrEventDataBuffer
//!
|
Re-enable all skipped extensions/structure/function and fix all compile errors to make the OpenXR-Hpp scripts compatible with the OpenXR-SDK 1.1.51 (see #53).