-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Improve xr gdnative #49301
Improve xr gdnative #49301
Conversation
ec7b60a
to
35da7c2
Compare
doc/classes/ProjectSettings.xml
Outdated
@@ -1593,6 +1593,9 @@ | |||
<member name="rendering/textures/vram_compression/import_s3tc" type="bool" setter="" getter="" default="true"> | |||
If [code]true[/code], the texture importer will import VRAM-compressed textures using the S3 Texture Compression algorithm. This algorithm is only supported on desktop platforms and consoles. | |||
</member> | |||
<member name="rendering/vr/enabled" type="bool" setter="" getter="" default="false"> | |||
If [code]true[/code], VR support is enabled in Godot, this ensures required shaders are compiled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it VR or XR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change comes from #48207, basically this enabled stereoscopic rendering which I guess has a purpose for both AR and VR. Possibly renaming this setting to XR might be more future proof.
Rebase issues not withstanding, this now does enough for the OpenVR plugin to work. There are a number of shortcuts in place so I'll be prettying up things in the next couple of days. |
35da7c2
to
89025ff
Compare
I can verify that it works. However, I can see that rendering is not enabled?
Had to convert Transform to Transform3D. Quat to Quaternion. Some of the GDNative XR interface changed. |
89025ff
to
044ff50
Compare
@@ -8318,3 +8328,23 @@ RenderingDeviceVulkan::~RenderingDeviceVulkan() { | |||
context->local_device_free(local_device); | |||
} | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reduz I'm not happy about exposing these this way, but I don't see any other way atm. Open to suggestions. Note that this is purely so we can send this data to the GDNative XR plugin. OpenVR needs this, OpenXR likely as well.
@@ -946,6 +946,9 @@ class RenderingDeviceVulkan : public RenderingDevice { | |||
virtual Error texture_clear(RID p_texture, const Color &p_color, uint32_t p_base_mipmap, uint32_t p_mipmaps, uint32_t p_base_layer, uint32_t p_layers, uint32_t p_post_barrier = BARRIER_MASK_ALL); | |||
virtual Error texture_resolve_multisample(RID p_from_texture, RID p_to_texture, uint32_t p_post_barrier = BARRIER_MASK_ALL); | |||
|
|||
// for now to get access to VkImage | |||
virtual void *texture_get_vulkan_image(const RID p_texture); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reduz similarly this one, I need access to VkImage
(which is a pointer), I'm casting it to void *
so the rest of the engine doesn't need to know. Interestingly enough OpenVR ends up casting it to uint64_t
before submitting it to the VR Compositor.
"major": 1, | ||
"minor": 1 | ||
"major": 4, | ||
"minor": 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renumbered this to 4.0
, might be better to just name it 2.0
, as we're breaking the API to something entirely new for Vulkan anyway it didn't make sense to keep this at 1.1
.
@@ -48,7 +48,7 @@ typedef struct { | |||
godot_gdnative_api_version version; /* version of our API */ | |||
void *(*constructor)(godot_object *); | |||
void (*destructor)(void *); | |||
godot_string (*get_name)(const void *); | |||
void (*get_name)(const void *, godot_string *); | |||
godot_int (*get_capabilities)(const void *); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May end up making similar changes in a few other API calls after discussing with @vnen. Seeing string allocates memory this seems to be a safer way to ensure there are no memory leaks.
godot_real_t GDAPI godot_xr_get_worldscale(); | ||
godot_transform3d GDAPI godot_xr_get_reference_frame(); | ||
|
||
// helper functions for rendering | ||
// helper functions for rendering (deprecated) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many of these functions will be removed before I'm done with this.
ERR_FAIL_COND_V(interface == nullptr, blit_to_screen); | ||
|
||
// commit_views can do callbacks to `godot_xr_blit_layer` to blit output to screen. This is ignored if this isn't the main view | ||
interface->commit_views(data, (void *)&blit_to_screen, (const godot_rid *)&p_render_target, (godot_rect2 *)&p_screen_rect); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking of using a RID for blit_to_screen to enable these callbacks for preview output.
const Rect2 *rect = (const Rect2 *)p_rect; | ||
|
||
BlitToScreen blit; | ||
blit.render_target = *render_target; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add a source rect option to BlitToScreen, as we're mostly using this for previewing an image on screen that is properly displayed inside of the headset, it's often only part of the image we're showing.
Yeah did all those but as I was without internet didn't have a chance to push it all in yet. Those are all changes on godot-cpp so also make sure you're on the correct version of that. |
6ffc8a8
to
a2dfdb6
Compare
So on some implementations |
a2dfdb6
to
afac489
Compare
Leaving this to harvest stuff from, but with GDNative being retired it is being superseeded by #52003 |
Now that we've merged the GD Extensions changes I've moved the remaining changes into |
Depends on #48207
This PR adds additional changes to XRInterfaceGDNative and related structures to enable writing XR plugins for Godot 4.
Breaking changes (some of these I'm still working on, some coming from 48207):
commit_views
is_stereo
was replaced byget_view_count
get_name
now has String as parameter, not return valuegodot_xr_get_worldscale
will be removed (useXRServer
)will be removed (use
XRServer`)godot_xr_*_controller*
will be removed (useXRPositionalTracker
)Currently deprecated but will be re-introduced in another form:
get_external_texture_for_eye
get_external_depth_for_eye