Skip to content

Commit

Permalink
Have OpenXR create a depth texture chain so we can supply our depth b…
Browse files Browse the repository at this point in the history
…uffer
  • Loading branch information
BastiaanOlij committed Mar 1, 2022
1 parent f8c4e59 commit 51a2c7c
Show file tree
Hide file tree
Showing 7 changed files with 320 additions and 149 deletions.
1 change: 1 addition & 0 deletions demo/addons/godot-openxr/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changes to the Godot OpenXR asset
1.3.0
-------------------
- Added default interaction profiles for Samsung Odyssey, HTC Cosmos, HTC Focus and Huawei controllers.
- Depth buffers are now created by OpenXR and used by Godot enabling advanced reprojection features in OpenXR.

1.2.0
-------------------
Expand Down
15 changes: 12 additions & 3 deletions src/ARVRInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ typedef struct arvr_data_struct {
OpenXRApi *openxr_api;

bool has_external_texture_support;
bool has_external_depth_support;
} arvr_data_struct;

godot_string godot_arvr_get_name(const void *p_data) {
Expand Down Expand Up @@ -294,7 +295,7 @@ void godot_arvr_commit_for_eye(void *p_data, godot_int p_eye, godot_rid *p_rende

if (arvr_data->openxr_api != nullptr) {
uint32_t texid = godot::arvr_api->godot_arvr_get_texid(p_render_target);
arvr_data->openxr_api->render_openxr(p_eye - 1, texid, arvr_data->has_external_texture_support);
arvr_data->openxr_api->render_openxr(p_eye - 1, texid, arvr_data->has_external_texture_support, arvr_data->has_external_depth_support);
}
}

Expand Down Expand Up @@ -367,8 +368,16 @@ int godot_arvr_get_camera_feed_id(void *) {
}

int godot_arvr_get_external_depth_for_eye(void *p_data, int p_eye) {
// stub
return 0;
arvr_data_struct *arvr_data = (arvr_data_struct *)p_data;

// this only gets called from Godot 3.2 and newer, allows us to use
// OpenXR swapchain directly.

if (arvr_data->openxr_api != nullptr) {
return arvr_data->openxr_api->get_external_depthbuffer_for_eye(p_eye - 1, &arvr_data->has_external_depth_support);
} else {
return 0;
}
}

const godot_arvr_interface_gdnative interface_struct = {
Expand Down
Loading

0 comments on commit 51a2c7c

Please sign in to comment.