Commit 05e7b56e authored by Kevin Qin's avatar Kevin Qin Committed by Commit Bot

OpenXR Remove Unnecessary Calls that are Called Every Frame

There are several problems with current openxr implementation:
1. stage bounds is fixed and only need to be set once.
2. Some VRDisplayinfo variables don't need to wait for session start
to be populated on every frame.

Change-Id: I9c0e6b8aea3560f5694a0b818f827cd2c0f30e01
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1832484
Commit-Queue: Zheng Qin <zheqi@microsoft.com>
Reviewed-by: default avatarAlexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710176}
parent 0f3b5fd3
...@@ -241,6 +241,7 @@ XrResult OpenXrApiWrapper::InitSession( ...@@ -241,6 +241,7 @@ XrResult OpenXrApiWrapper::InitSession(
// It's ok if stage_space_ fails since not all OpenXR devices are required to // It's ok if stage_space_ fails since not all OpenXR devices are required to
// support this reference space. // support this reference space.
CreateSpace(XR_REFERENCE_SPACE_TYPE_STAGE, &stage_space_); CreateSpace(XR_REFERENCE_SPACE_TYPE_STAGE, &stage_space_);
UpdateStageBounds();
// Since the objects in these arrays are used on every frame, // Since the objects in these arrays are used on every frame,
// we don't want to create and destroy these objects every frame, // we don't want to create and destroy these objects every frame,
...@@ -638,17 +639,23 @@ std::string OpenXrApiWrapper::GetRuntimeName() const { ...@@ -638,17 +639,23 @@ std::string OpenXrApiWrapper::GetRuntimeName() const {
} }
} }
XrResult OpenXrApiWrapper::GetStageBounds(XrExtent2Df* stage_bounds) const { // stage bounds is fixed unless we received event
DCHECK(stage_bounds); // XrEventDataReferenceSpaceChangePending
XrResult OpenXrApiWrapper::UpdateStageBounds() {
DCHECK(HasSession()); DCHECK(HasSession());
XrResult xr_result;
xr_result = xrGetReferenceSpaceBoundsRect(
session_, XR_REFERENCE_SPACE_TYPE_STAGE, &stage_bounds_);
if (XR_FAILED(xr_result)) {
stage_bounds_.height = 0;
stage_bounds_.width = 0;
}
return xrGetReferenceSpaceBoundsRect(session_, XR_REFERENCE_SPACE_TYPE_STAGE, return xr_result;
stage_bounds);
} }
bool OpenXrApiWrapper::GetStageParameters( bool OpenXrApiWrapper::GetStageParameters(XrExtent2Df* stage_bounds,
XrExtent2Df* stage_bounds, gfx::Transform* local_from_stage) {
gfx::Transform* local_from_stage) const {
DCHECK(stage_bounds); DCHECK(stage_bounds);
DCHECK(local_from_stage); DCHECK(local_from_stage);
DCHECK(HasSession()); DCHECK(HasSession());
...@@ -659,8 +666,7 @@ bool OpenXrApiWrapper::GetStageParameters( ...@@ -659,8 +666,7 @@ bool OpenXrApiWrapper::GetStageParameters(
if (!HasSpace(XR_REFERENCE_SPACE_TYPE_STAGE)) if (!HasSpace(XR_REFERENCE_SPACE_TYPE_STAGE))
return false; return false;
if (XR_FAILED(GetStageBounds(stage_bounds))) *stage_bounds = stage_bounds_;
return false;
XrSpaceLocation local_from_stage_location = {XR_TYPE_SPACE_LOCATION}; XrSpaceLocation local_from_stage_location = {XR_TYPE_SPACE_LOCATION};
if (FAILED(xrLocateSpace(local_space_, stage_space_, if (FAILED(xrLocateSpace(local_space_, stage_space_,
......
...@@ -58,7 +58,7 @@ class OpenXrApiWrapper { ...@@ -58,7 +58,7 @@ class OpenXrApiWrapper {
XrResult GetLuid(LUID* luid) const; XrResult GetLuid(LUID* luid) const;
std::string GetRuntimeName() const; std::string GetRuntimeName() const;
bool GetStageParameters(XrExtent2Df* stage_bounds, bool GetStageParameters(XrExtent2Df* stage_bounds,
gfx::Transform* local_from_stage) const; gfx::Transform* local_from_stage);
static void DEVICE_VR_EXPORT SetTestHook(VRTestHook* hook); static void DEVICE_VR_EXPORT SetTestHook(VRTestHook* hook);
...@@ -92,7 +92,7 @@ class OpenXrApiWrapper { ...@@ -92,7 +92,7 @@ class OpenXrApiWrapper {
bool HasFrameState() const; bool HasFrameState() const;
uint32_t GetRecommendedSwapchainSampleCount() const; uint32_t GetRecommendedSwapchainSampleCount() const;
XrResult GetStageBounds(XrExtent2Df* stage_bounds) const; XrResult UpdateStageBounds();
bool session_ended_; bool session_ended_;
...@@ -107,6 +107,7 @@ class OpenXrApiWrapper { ...@@ -107,6 +107,7 @@ class OpenXrApiWrapper {
XrSystemId system_; XrSystemId system_;
std::vector<XrViewConfigurationView> view_configs_; std::vector<XrViewConfigurationView> view_configs_;
XrEnvironmentBlendMode blend_mode_; XrEnvironmentBlendMode blend_mode_;
XrExtent2Df stage_bounds_;
// These objects are valid only while a session is active, // These objects are valid only while a session is active,
// and stay constant throughout the lifetime of a session. // and stay constant throughout the lifetime of a session.
......
...@@ -155,12 +155,6 @@ void OpenXrDevice::OnRequestSessionResult( ...@@ -155,12 +155,6 @@ void OpenXrDevice::OnRequestSessionResult(
OnStartPresenting(); OnStartPresenting();
EnsureRenderLoop();
gfx::Size view_size = render_loop_->GetViewSize();
display_info_->left_eye->render_width = view_size.width();
display_info_->right_eye->render_width = view_size.width();
display_info_->left_eye->render_height = view_size.height();
display_info_->right_eye->render_height = view_size.height();
session->display_info = display_info_.Clone(); session->display_info = display_info_.Clone();
std::move(callback).Run( std::move(callback).Run(
......
...@@ -23,10 +23,6 @@ OpenXrRenderLoop::~OpenXrRenderLoop() { ...@@ -23,10 +23,6 @@ OpenXrRenderLoop::~OpenXrRenderLoop() {
Stop(); Stop();
} }
gfx::Size OpenXrRenderLoop::GetViewSize() const {
return openxr_->GetViewSize();
}
mojom::XRFrameDataPtr OpenXrRenderLoop::GetNextFrameData() { mojom::XRFrameDataPtr OpenXrRenderLoop::GetNextFrameData() {
mojom::XRFrameDataPtr frame_data = mojom::XRFrameData::New(); mojom::XRFrameDataPtr frame_data = mojom::XRFrameData::New();
frame_data->frame_id = next_frame_id_; frame_data->frame_id = next_frame_id_;
...@@ -56,23 +52,21 @@ mojom::XRFrameDataPtr OpenXrRenderLoop::GetNextFrameData() { ...@@ -56,23 +52,21 @@ mojom::XRFrameDataPtr OpenXrRenderLoop::GetNextFrameData() {
frame_data->pose->position = position; frame_data->pose->position = position;
} }
bool updated_display_info = UpdateDisplayInfo();
bool updated_eye_parameters = UpdateEyeParameters(); bool updated_eye_parameters = UpdateEyeParameters();
bool updated_stage_parameters = UpdateStageParameters();
if (updated_eye_parameters) { if (updated_eye_parameters) {
frame_data->left_eye = current_display_info_->left_eye.Clone(); frame_data->left_eye = current_display_info_->left_eye.Clone();
frame_data->right_eye = current_display_info_->right_eye.Clone(); frame_data->right_eye = current_display_info_->right_eye.Clone();
} }
bool updated_stage_parameters = UpdateStageParameters();
if (updated_stage_parameters) { if (updated_stage_parameters) {
frame_data->stage_parameters_updated = true; frame_data->stage_parameters_updated = true;
frame_data->stage_parameters = frame_data->stage_parameters =
current_display_info_->stage_parameters.Clone(); current_display_info_->stage_parameters.Clone();
} }
if (updated_display_info || updated_eye_parameters || if (updated_eye_parameters || updated_stage_parameters) {
updated_stage_parameters) {
main_thread_task_runner_->PostTask( main_thread_task_runner_->PostTask(
FROM_HERE, base::BindOnce(on_display_info_changed_, FROM_HERE, base::BindOnce(on_display_info_changed_,
current_display_info_.Clone())); current_display_info_.Clone()));
...@@ -108,10 +102,11 @@ bool OpenXrRenderLoop::StartRuntime() { ...@@ -108,10 +102,11 @@ bool OpenXrRenderLoop::StartRuntime() {
// Starting session succeeded so we can set the member variable. // Starting session succeeded so we can set the member variable.
// Any additional code added below this should never fail. // Any additional code added below this should never fail.
openxr_ = std::move(openxr); openxr_ = std::move(openxr);
texture_helper_.SetDefaultSize(GetViewSize()); texture_helper_.SetDefaultSize(openxr_->GetViewSize());
DCHECK(openxr_); DCHECK(openxr_);
DCHECK(input_helper_); DCHECK(input_helper_);
InitializeDisplayInfo();
return true; return true;
} }
...@@ -143,69 +138,56 @@ bool OpenXrRenderLoop::SubmitCompositedFrame() { ...@@ -143,69 +138,56 @@ bool OpenXrRenderLoop::SubmitCompositedFrame() {
} }
// Return true if display info has changed. // Return true if display info has changed.
bool OpenXrRenderLoop::UpdateDisplayInfo() { void OpenXrRenderLoop::InitializeDisplayInfo() {
bool changed = false;
if (!current_display_info_) { if (!current_display_info_) {
current_display_info_ = mojom::VRDisplayInfo::New(); current_display_info_ = mojom::VRDisplayInfo::New();
current_display_info_->id = device::mojom::XRDeviceId::OPENXR_DEVICE_ID; current_display_info_->right_eye = mojom::VREyeParameters::New();
current_display_info_->left_eye = mojom::VREyeParameters::New();
current_display_info_->capabilities = mojom::VRDisplayCapabilities::New();
current_display_info_->capabilities->can_provide_environment_integration =
false;
current_display_info_->webvr_default_framebuffer_scale = 1.0f;
current_display_info_->webxr_default_framebuffer_scale = 1.0f;
changed = true;
} }
std::string runtime_name = openxr_->GetRuntimeName(); current_display_info_->id = device::mojom::XRDeviceId::OPENXR_DEVICE_ID;
if (current_display_info_->display_name != runtime_name) { current_display_info_->display_name = openxr_->GetRuntimeName();
current_display_info_->display_name = runtime_name;
changed = true;
}
bool has_position = openxr_->HasPosition(); current_display_info_->capabilities = mojom::VRDisplayCapabilities::New();
if (current_display_info_->capabilities->has_position != has_position) { current_display_info_->capabilities->can_provide_environment_integration =
current_display_info_->capabilities->has_position = has_position; false;
changed = true; current_display_info_->capabilities->has_position = openxr_->HasPosition();
}
// OpenXR is initialized when creating the instance and getting the system // OpenXR is initialized when creating the instance and getting the system
// was successful. If we are able to get a system, then we can present to // was successful. If we are able to get a system, then we can present to
// an external display. // an external display.
bool openxr_initialized = openxr_->IsInitialized(); current_display_info_->capabilities->has_external_display =
if (current_display_info_->capabilities->has_external_display != openxr_->IsInitialized();
openxr_initialized || current_display_info_->capabilities->can_present = openxr_->IsInitialized();
current_display_info_->capabilities->can_present != openxr_initialized) {
current_display_info_->capabilities->has_external_display = current_display_info_->webvr_default_framebuffer_scale = 1.0f;
openxr_initialized; current_display_info_->webxr_default_framebuffer_scale = 1.0f;
current_display_info_->capabilities->can_present = openxr_initialized;
changed = true; gfx::Size view_size = openxr_->GetViewSize();
} current_display_info_->left_eye->render_width = view_size.width();
current_display_info_->right_eye->render_width = view_size.width();
return changed; current_display_info_->left_eye->render_height = view_size.height();
current_display_info_->right_eye->render_height = view_size.height();
// display info can't be send without fov info because of the mojo definition.
current_display_info_->left_eye->field_of_view =
mojom::VRFieldOfView::New(45.0f, 45.0f, 45.0f, 45.0f);
current_display_info_->right_eye->field_of_view =
current_display_info_->left_eye->field_of_view.Clone();
main_thread_task_runner_->PostTask(
FROM_HERE,
base::BindOnce(on_display_info_changed_, current_display_info_.Clone()));
} }
// return true if either left_eye or right_eye updated. // return true if either left_eye or right_eye updated.
bool OpenXrRenderLoop::UpdateEyeParameters() { bool OpenXrRenderLoop::UpdateEyeParameters() {
bool changed = false; bool changed = false;
if (!current_display_info_->left_eye) {
current_display_info_->left_eye = mojom::VREyeParameters::New();
changed = true;
}
if (!current_display_info_->right_eye) {
current_display_info_->right_eye = mojom::VREyeParameters::New();
changed = true;
}
XrView left; XrView left;
XrView right; XrView right;
openxr_->GetHeadFromEyes(&left, &right); openxr_->GetHeadFromEyes(&left, &right);
gfx::Size view_size = GetViewSize(); gfx::Size view_size = openxr_->GetViewSize();
changed |= UpdateEye(left, view_size, &current_display_info_->left_eye); changed |= UpdateEye(left, view_size, &current_display_info_->left_eye);
......
...@@ -24,8 +24,6 @@ class OpenXrRenderLoop : public XRCompositorCommon { ...@@ -24,8 +24,6 @@ class OpenXrRenderLoop : public XRCompositorCommon {
on_display_info_changed); on_display_info_changed);
~OpenXrRenderLoop() override; ~OpenXrRenderLoop() override;
gfx::Size GetViewSize() const;
private: private:
// XRDeviceAbstraction: // XRDeviceAbstraction:
mojom::XRFrameDataPtr GetNextFrameData() override; mojom::XRFrameDataPtr GetNextFrameData() override;
...@@ -36,7 +34,7 @@ class OpenXrRenderLoop : public XRCompositorCommon { ...@@ -36,7 +34,7 @@ class OpenXrRenderLoop : public XRCompositorCommon {
bool HasSessionEnded() override; bool HasSessionEnded() override;
bool SubmitCompositedFrame() override; bool SubmitCompositedFrame() override;
bool UpdateDisplayInfo(); void InitializeDisplayInfo();
bool UpdateEyeParameters(); bool UpdateEyeParameters();
bool UpdateEye(const XrView& view_head, bool UpdateEye(const XrView& view_head,
const gfx::Size& view_size, const gfx::Size& view_size,
......
...@@ -23,7 +23,7 @@ XrResult xrAcquireSwapchainImage( ...@@ -23,7 +23,7 @@ XrResult xrAcquireSwapchainImage(
XrSwapchain swapchain, XrSwapchain swapchain,
const XrSwapchainImageAcquireInfo* acquire_info, const XrSwapchainImageAcquireInfo* acquire_info,
uint32_t* index) { uint32_t* index) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSwapchain(swapchain)); RETURN_IF_XR_FAILED(g_test_helper.ValidateSwapchain(swapchain));
...@@ -39,7 +39,7 @@ XrResult xrAcquireSwapchainImage( ...@@ -39,7 +39,7 @@ XrResult xrAcquireSwapchainImage(
XrResult xrAttachSessionActionSets( XrResult xrAttachSessionActionSets(
XrSession session, XrSession session,
const XrSessionActionSetsAttachInfo* attach_info) { const XrSessionActionSetsAttachInfo* attach_info) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session)); RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session));
...@@ -49,7 +49,7 @@ XrResult xrAttachSessionActionSets( ...@@ -49,7 +49,7 @@ XrResult xrAttachSessionActionSets(
XrResult xrBeginFrame(XrSession session, XrResult xrBeginFrame(XrSession session,
const XrFrameBeginInfo* frame_begin_info) { const XrFrameBeginInfo* frame_begin_info) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session)); RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session));
...@@ -61,7 +61,7 @@ XrResult xrBeginFrame(XrSession session, ...@@ -61,7 +61,7 @@ XrResult xrBeginFrame(XrSession session,
XrResult xrBeginSession(XrSession session, XrResult xrBeginSession(XrSession session,
const XrSessionBeginInfo* begin_info) { const XrSessionBeginInfo* begin_info) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session)); RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session));
...@@ -80,7 +80,7 @@ XrResult xrBeginSession(XrSession session, ...@@ -80,7 +80,7 @@ XrResult xrBeginSession(XrSession session,
XrResult xrCreateAction(XrActionSet action_set, XrResult xrCreateAction(XrActionSet action_set,
const XrActionCreateInfo* create_info, const XrActionCreateInfo* create_info,
XrAction* action) { XrAction* action) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateActionSet(action_set)); RETURN_IF_XR_FAILED(g_test_helper.ValidateActionSet(action_set));
...@@ -93,7 +93,7 @@ XrResult xrCreateAction(XrActionSet action_set, ...@@ -93,7 +93,7 @@ XrResult xrCreateAction(XrActionSet action_set,
XrResult xrCreateActionSet(XrInstance instance, XrResult xrCreateActionSet(XrInstance instance,
const XrActionSetCreateInfo* create_info, const XrActionSetCreateInfo* create_info,
XrActionSet* action_set) { XrActionSet* action_set) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateInstance(instance)); RETURN_IF_XR_FAILED(g_test_helper.ValidateInstance(instance));
...@@ -106,7 +106,7 @@ XrResult xrCreateActionSet(XrInstance instance, ...@@ -106,7 +106,7 @@ XrResult xrCreateActionSet(XrInstance instance,
XrResult xrCreateActionSpace(XrSession session, XrResult xrCreateActionSpace(XrSession session,
const XrActionSpaceCreateInfo* create_info, const XrActionSpaceCreateInfo* create_info,
XrSpace* space) { XrSpace* space) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session)); RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session));
...@@ -120,7 +120,7 @@ XrResult xrCreateActionSpace(XrSession session, ...@@ -120,7 +120,7 @@ XrResult xrCreateActionSpace(XrSession session,
XrResult xrCreateInstance(const XrInstanceCreateInfo* create_info, XrResult xrCreateInstance(const XrInstanceCreateInfo* create_info,
XrInstance* instance) { XrInstance* instance) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
RETURN_IF(create_info->applicationInfo.apiVersion != XR_CURRENT_API_VERSION, RETURN_IF(create_info->applicationInfo.apiVersion != XR_CURRENT_API_VERSION,
XR_ERROR_API_VERSION_UNSUPPORTED, "apiVersion unsupported"); XR_ERROR_API_VERSION_UNSUPPORTED, "apiVersion unsupported");
...@@ -154,7 +154,7 @@ XrResult xrCreateInstance(const XrInstanceCreateInfo* create_info, ...@@ -154,7 +154,7 @@ XrResult xrCreateInstance(const XrInstanceCreateInfo* create_info,
XrResult xrCreateReferenceSpace(XrSession session, XrResult xrCreateReferenceSpace(XrSession session,
const XrReferenceSpaceCreateInfo* create_info, const XrReferenceSpaceCreateInfo* create_info,
XrSpace* space) { XrSpace* space) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session)); RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session));
...@@ -178,7 +178,7 @@ XrResult xrCreateReferenceSpace(XrSession session, ...@@ -178,7 +178,7 @@ XrResult xrCreateReferenceSpace(XrSession session,
XrResult xrCreateSession(XrInstance instance, XrResult xrCreateSession(XrInstance instance,
const XrSessionCreateInfo* create_info, const XrSessionCreateInfo* create_info,
XrSession* session) { XrSession* session) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateInstance(instance)); RETURN_IF_XR_FAILED(g_test_helper.ValidateInstance(instance));
...@@ -203,7 +203,7 @@ XrResult xrCreateSession(XrInstance instance, ...@@ -203,7 +203,7 @@ XrResult xrCreateSession(XrInstance instance,
XrResult xrCreateSwapchain(XrSession session, XrResult xrCreateSwapchain(XrSession session,
const XrSwapchainCreateInfo* create_info, const XrSwapchainCreateInfo* create_info,
XrSwapchain* swapchain) { XrSwapchain* swapchain) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session)); RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session));
...@@ -238,7 +238,7 @@ XrResult xrCreateSwapchain(XrSession session, ...@@ -238,7 +238,7 @@ XrResult xrCreateSwapchain(XrSession session,
} }
XrResult xrDestroyActionSet(XrActionSet action_set) { XrResult xrDestroyActionSet(XrActionSet action_set) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateActionSet(action_set)); RETURN_IF_XR_FAILED(g_test_helper.ValidateActionSet(action_set));
...@@ -246,7 +246,7 @@ XrResult xrDestroyActionSet(XrActionSet action_set) { ...@@ -246,7 +246,7 @@ XrResult xrDestroyActionSet(XrActionSet action_set) {
} }
XrResult xrDestroyInstance(XrInstance instance) { XrResult xrDestroyInstance(XrInstance instance) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateInstance(instance)); RETURN_IF_XR_FAILED(g_test_helper.ValidateInstance(instance));
...@@ -255,7 +255,7 @@ XrResult xrDestroyInstance(XrInstance instance) { ...@@ -255,7 +255,7 @@ XrResult xrDestroyInstance(XrInstance instance) {
} }
XrResult xrDestroySpace(XrSpace space) { XrResult xrDestroySpace(XrSpace space) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSpace(space)); RETURN_IF_XR_FAILED(g_test_helper.ValidateSpace(space));
...@@ -264,7 +264,7 @@ XrResult xrDestroySpace(XrSpace space) { ...@@ -264,7 +264,7 @@ XrResult xrDestroySpace(XrSpace space) {
} }
XrResult xrEndFrame(XrSession session, const XrFrameEndInfo* frame_end_info) { XrResult xrEndFrame(XrSession session, const XrFrameEndInfo* frame_end_info) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session)); RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session));
...@@ -305,7 +305,7 @@ XrResult xrEndFrame(XrSession session, const XrFrameEndInfo* frame_end_info) { ...@@ -305,7 +305,7 @@ XrResult xrEndFrame(XrSession session, const XrFrameEndInfo* frame_end_info) {
} }
XrResult xrEndSession(XrSession session) { XrResult xrEndSession(XrSession session) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session)); RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session));
...@@ -321,7 +321,7 @@ XrResult xrEnumerateEnvironmentBlendModes( ...@@ -321,7 +321,7 @@ XrResult xrEnumerateEnvironmentBlendModes(
uint32_t environmentBlendModeCapacityInput, uint32_t environmentBlendModeCapacityInput,
uint32_t* environmentBlendModeCountOutput, uint32_t* environmentBlendModeCountOutput,
XrEnvironmentBlendMode* environmentBlendModes) { XrEnvironmentBlendMode* environmentBlendModes) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateInstance(instance)); RETURN_IF_XR_FAILED(g_test_helper.ValidateInstance(instance));
...@@ -344,7 +344,7 @@ XrResult xrEnumerateInstanceExtensionProperties( ...@@ -344,7 +344,7 @@ XrResult xrEnumerateInstanceExtensionProperties(
uint32_t property_capacity_input, uint32_t property_capacity_input,
uint32_t* property_count_output, uint32_t* property_count_output,
XrExtensionProperties* properties) { XrExtensionProperties* properties) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
RETURN_IF( RETURN_IF(
property_capacity_input < OpenXrTestHelper::NumExtensionsSupported() && property_capacity_input < OpenXrTestHelper::NumExtensionsSupported() &&
...@@ -372,7 +372,7 @@ XrResult xrEnumerateViewConfigurationViews( ...@@ -372,7 +372,7 @@ XrResult xrEnumerateViewConfigurationViews(
uint32_t view_capacity_input, uint32_t view_capacity_input,
uint32_t* view_count_output, uint32_t* view_count_output,
XrViewConfigurationView* views) { XrViewConfigurationView* views) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateInstance(instance)); RETURN_IF_XR_FAILED(g_test_helper.ValidateInstance(instance));
...@@ -395,7 +395,7 @@ XrResult xrEnumerateSwapchainImages(XrSwapchain swapchain, ...@@ -395,7 +395,7 @@ XrResult xrEnumerateSwapchainImages(XrSwapchain swapchain,
uint32_t image_capacity_input, uint32_t image_capacity_input,
uint32_t* image_count_output, uint32_t* image_count_output,
XrSwapchainImageBaseHeader* images) { XrSwapchainImageBaseHeader* images) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSwapchain(swapchain)); RETURN_IF_XR_FAILED(g_test_helper.ValidateSwapchain(swapchain));
...@@ -431,7 +431,7 @@ XrResult xrGetD3D11GraphicsRequirementsKHR( ...@@ -431,7 +431,7 @@ XrResult xrGetD3D11GraphicsRequirementsKHR(
XrInstance instance, XrInstance instance,
XrSystemId system_id, XrSystemId system_id,
XrGraphicsRequirementsD3D11KHR* graphics_requirements) { XrGraphicsRequirementsD3D11KHR* graphics_requirements) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateInstance(instance)); RETURN_IF_XR_FAILED(g_test_helper.ValidateInstance(instance));
...@@ -463,7 +463,7 @@ XrResult xrGetD3D11GraphicsRequirementsKHR( ...@@ -463,7 +463,7 @@ XrResult xrGetD3D11GraphicsRequirementsKHR(
XrResult xrGetActionStateFloat(XrSession session, XrResult xrGetActionStateFloat(XrSession session,
const XrActionStateGetInfo* get_info, const XrActionStateGetInfo* get_info,
XrActionStateFloat* state) { XrActionStateFloat* state) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session)); RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session));
RETURN_IF(get_info->type != XR_TYPE_ACTION_STATE_GET_INFO, RETURN_IF(get_info->type != XR_TYPE_ACTION_STATE_GET_INFO,
...@@ -483,7 +483,7 @@ XrResult xrGetActionStateFloat(XrSession session, ...@@ -483,7 +483,7 @@ XrResult xrGetActionStateFloat(XrSession session,
XrResult xrGetActionStateBoolean(XrSession session, XrResult xrGetActionStateBoolean(XrSession session,
const XrActionStateGetInfo* get_info, const XrActionStateGetInfo* get_info,
XrActionStateBoolean* state) { XrActionStateBoolean* state) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session)); RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session));
...@@ -504,7 +504,7 @@ XrResult xrGetActionStateBoolean(XrSession session, ...@@ -504,7 +504,7 @@ XrResult xrGetActionStateBoolean(XrSession session,
XrResult xrGetActionStateVector2f(XrSession session, XrResult xrGetActionStateVector2f(XrSession session,
const XrActionStateGetInfo* get_info, const XrActionStateGetInfo* get_info,
XrActionStateVector2f* state) { XrActionStateVector2f* state) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session)); RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session));
...@@ -525,7 +525,7 @@ XrResult xrGetActionStateVector2f(XrSession session, ...@@ -525,7 +525,7 @@ XrResult xrGetActionStateVector2f(XrSession session,
XrResult xrGetActionStatePose(XrSession session, XrResult xrGetActionStatePose(XrSession session,
const XrActionStateGetInfo* get_info, const XrActionStateGetInfo* get_info,
XrActionStatePose* state) { XrActionStatePose* state) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session)); RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session));
...@@ -545,21 +545,38 @@ XrResult xrGetActionStatePose(XrSession session, ...@@ -545,21 +545,38 @@ XrResult xrGetActionStatePose(XrSession session,
XrResult xrGetInstanceProperties(XrInstance instance, XrResult xrGetInstanceProperties(XrInstance instance,
XrInstanceProperties* instanceProperties) { XrInstanceProperties* instanceProperties) {
// TODO(https://crbug.com/996502) DVLOG(2) << __FUNCTION__;
return XR_ERROR_FUNCTION_UNSUPPORTED; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateInstance(instance));
RETURN_IF(instanceProperties->type != XR_TYPE_INSTANCE_PROPERTIES,
XR_ERROR_VALIDATION_FAILURE,
"xrGetReferenceSpaceBoundsRect type is not stage");
errno_t error =
strcpy_s(instanceProperties->runtimeName, "OpenXR Mock Runtime");
DCHECK(error == 0);
return XR_SUCCESS;
} }
XrResult xrGetReferenceSpaceBoundsRect(XrSession session, XrResult xrGetReferenceSpaceBoundsRect(XrSession session,
XrReferenceSpaceType referenceSpaceType, XrReferenceSpaceType referenceSpaceType,
XrExtent2Df* bounds) { XrExtent2Df* bounds) {
// TODO(https://crbug.com/996502) DVLOG(2) << __FUNCTION__;
return XR_ERROR_FUNCTION_UNSUPPORTED; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session));
RETURN_IF(referenceSpaceType != XR_REFERENCE_SPACE_TYPE_STAGE,
XR_ERROR_VALIDATION_FAILURE,
"xrGetReferenceSpaceBoundsRect type is not stage");
bounds->width = 0;
bounds->height = 0;
return XR_SUCCESS;
} }
XrResult xrGetSystem(XrInstance instance, XrResult xrGetSystem(XrInstance instance,
const XrSystemGetInfo* get_info, const XrSystemGetInfo* get_info,
XrSystemId* system_id) { XrSystemId* system_id) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateInstance(instance)); RETURN_IF_XR_FAILED(g_test_helper.ValidateInstance(instance));
...@@ -576,7 +593,6 @@ XrResult xrGetSystem(XrInstance instance, ...@@ -576,7 +593,6 @@ XrResult xrGetSystem(XrInstance instance,
XrResult xrGetSystemProperties(XrInstance instance, XrResult xrGetSystemProperties(XrInstance instance,
XrSystemId systemId, XrSystemId systemId,
XrSystemProperties* properties) { XrSystemProperties* properties) {
// TODO(https://crbug.com/996502)
properties->trackingProperties.positionTracking = true; properties->trackingProperties.positionTracking = true;
return XR_SUCCESS; return XR_SUCCESS;
} }
...@@ -585,7 +601,7 @@ XrResult xrLocateSpace(XrSpace space, ...@@ -585,7 +601,7 @@ XrResult xrLocateSpace(XrSpace space,
XrSpace baseSpace, XrSpace baseSpace,
XrTime time, XrTime time,
XrSpaceLocation* location) { XrSpaceLocation* location) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSpace(space)); RETURN_IF_XR_FAILED(g_test_helper.ValidateSpace(space));
...@@ -606,7 +622,7 @@ XrResult xrLocateViews(XrSession session, ...@@ -606,7 +622,7 @@ XrResult xrLocateViews(XrSession session,
uint32_t view_capacity_input, uint32_t view_capacity_input,
uint32_t* view_count_output, uint32_t* view_count_output,
XrView* views) { XrView* views) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session)); RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session));
...@@ -631,7 +647,7 @@ XrResult xrLocateViews(XrSession session, ...@@ -631,7 +647,7 @@ XrResult xrLocateViews(XrSession session,
} }
XrResult xrPollEvent(XrInstance instance, XrEventDataBuffer* event_data) { XrResult xrPollEvent(XrInstance instance, XrEventDataBuffer* event_data) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateInstance(instance)); RETURN_IF_XR_FAILED(g_test_helper.ValidateInstance(instance));
...@@ -655,7 +671,7 @@ XrResult xrPollEvent(XrInstance instance, XrEventDataBuffer* event_data) { ...@@ -655,7 +671,7 @@ XrResult xrPollEvent(XrInstance instance, XrEventDataBuffer* event_data) {
XrResult xrReleaseSwapchainImage( XrResult xrReleaseSwapchainImage(
XrSwapchain swapchain, XrSwapchain swapchain,
const XrSwapchainImageReleaseInfo* release_info) { const XrSwapchainImageReleaseInfo* release_info) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSwapchain(swapchain)); RETURN_IF_XR_FAILED(g_test_helper.ValidateSwapchain(swapchain));
...@@ -669,7 +685,7 @@ XrResult xrReleaseSwapchainImage( ...@@ -669,7 +685,7 @@ XrResult xrReleaseSwapchainImage(
XrResult xrSuggestInteractionProfileBindings( XrResult xrSuggestInteractionProfileBindings(
XrInstance instance, XrInstance instance,
const XrInteractionProfileSuggestedBinding* suggested_bindings) { const XrInteractionProfileSuggestedBinding* suggested_bindings) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateInstance(instance)); RETURN_IF_XR_FAILED(g_test_helper.ValidateInstance(instance));
...@@ -699,7 +715,7 @@ XrResult xrSuggestInteractionProfileBindings( ...@@ -699,7 +715,7 @@ XrResult xrSuggestInteractionProfileBindings(
XrResult xrStringToPath(XrInstance instance, XrResult xrStringToPath(XrInstance instance,
const char* pathString, const char* pathString,
XrPath* path) { XrPath* path) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateInstance(instance)); RETURN_IF_XR_FAILED(g_test_helper.ValidateInstance(instance));
...@@ -710,7 +726,7 @@ XrResult xrStringToPath(XrInstance instance, ...@@ -710,7 +726,7 @@ XrResult xrStringToPath(XrInstance instance,
} }
XrResult xrSyncActions(XrSession session, const XrActionsSyncInfo* sync_info) { XrResult xrSyncActions(XrSession session, const XrActionsSyncInfo* sync_info) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session)); RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session));
...@@ -732,7 +748,7 @@ XrResult xrSyncActions(XrSession session, const XrActionsSyncInfo* sync_info) { ...@@ -732,7 +748,7 @@ XrResult xrSyncActions(XrSession session, const XrActionsSyncInfo* sync_info) {
XrResult xrWaitFrame(XrSession session, XrResult xrWaitFrame(XrSession session,
const XrFrameWaitInfo* frame_wait_info, const XrFrameWaitInfo* frame_wait_info,
XrFrameState* frame_state) { XrFrameState* frame_state) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session)); RETURN_IF_XR_FAILED(g_test_helper.ValidateSession(session));
...@@ -748,7 +764,7 @@ XrResult xrWaitFrame(XrSession session, ...@@ -748,7 +764,7 @@ XrResult xrWaitFrame(XrSession session,
XrResult xrWaitSwapchainImage(XrSwapchain swapchain, XrResult xrWaitSwapchainImage(XrSwapchain swapchain,
const XrSwapchainImageWaitInfo* wait_info) { const XrSwapchainImageWaitInfo* wait_info) {
DLOG(INFO) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
XrResult xr_result; XrResult xr_result;
RETURN_IF_XR_FAILED(g_test_helper.ValidateSwapchain(swapchain)); RETURN_IF_XR_FAILED(g_test_helper.ValidateSwapchain(swapchain));
......
...@@ -57,7 +57,7 @@ OpenXrTestHelper::OpenXrTestHelper() ...@@ -57,7 +57,7 @@ OpenXrTestHelper::OpenXrTestHelper()
session_state_(XR_SESSION_STATE_UNKNOWN), session_state_(XR_SESSION_STATE_UNKNOWN),
swapchain_(XR_NULL_HANDLE), swapchain_(XR_NULL_HANDLE),
acquired_swapchain_texture_(0), acquired_swapchain_texture_(0),
next_action_space_(0), next_space_(0),
next_predicted_display_time_(0) {} next_predicted_display_time_(0) {}
OpenXrTestHelper::~OpenXrTestHelper() = default; OpenXrTestHelper::~OpenXrTestHelper() = default;
...@@ -71,7 +71,7 @@ void OpenXrTestHelper::Reset() { ...@@ -71,7 +71,7 @@ void OpenXrTestHelper::Reset() {
system_id_ = 0; system_id_ = 0;
d3d_device_ = nullptr; d3d_device_ = nullptr;
acquired_swapchain_texture_ = 0; acquired_swapchain_texture_ = 0;
next_action_space_ = 0; next_space_ = 0;
next_predicted_display_time_ = 0; next_predicted_display_time_ = 0;
// vectors // vectors
...@@ -230,7 +230,7 @@ XrResult OpenXrTestHelper::GetActionStatePose(XrAction action, ...@@ -230,7 +230,7 @@ XrResult OpenXrTestHelper::GetActionStatePose(XrAction action,
} }
XrSpace OpenXrTestHelper::CreateReferenceSpace(XrReferenceSpaceType type) { XrSpace OpenXrTestHelper::CreateReferenceSpace(XrReferenceSpaceType type) {
XrSpace cur_space = TreatIntegerAsHandle<XrSpace>(++next_action_space_); XrSpace cur_space = TreatIntegerAsHandle<XrSpace>(++next_space_);
switch (type) { switch (type) {
case XR_REFERENCE_SPACE_TYPE_VIEW: case XR_REFERENCE_SPACE_TYPE_VIEW:
reference_spaces_[cur_space] = "/reference_space/view"; reference_spaces_[cur_space] = "/reference_space/view";
...@@ -296,7 +296,7 @@ XrActionSet OpenXrTestHelper::CreateActionSet( ...@@ -296,7 +296,7 @@ XrActionSet OpenXrTestHelper::CreateActionSet(
} }
XrSpace OpenXrTestHelper::CreateActionSpace(XrAction action) { XrSpace OpenXrTestHelper::CreateActionSpace(XrAction action) {
XrSpace cur_space = TreatIntegerAsHandle<XrSpace>(++next_action_space_); XrSpace cur_space = TreatIntegerAsHandle<XrSpace>(++next_space_);
action_spaces_[cur_space] = action; action_spaces_[cur_space] = action;
return cur_space; return cur_space;
} }
...@@ -334,7 +334,6 @@ XrResult OpenXrTestHelper::BindActionAndPath(XrActionSuggestedBinding binding) { ...@@ -334,7 +334,6 @@ XrResult OpenXrTestHelper::BindActionAndPath(XrActionSuggestedBinding binding) {
"not cupported with current test"); "not cupported with current test");
current_action.binding = binding.binding; current_action.binding = binding.binding;
std::string path_string = PathToString(current_action.binding); std::string path_string = PathToString(current_action.binding);
DLOG(ERROR) << path_string;
return XR_SUCCESS; return XR_SUCCESS;
} }
...@@ -550,7 +549,18 @@ void OpenXrTestHelper::LocateSpace(XrSpace space, XrPosef* pose) { ...@@ -550,7 +549,18 @@ void OpenXrTestHelper::LocateSpace(XrSpace space, XrPosef* pose) {
base::Optional<gfx::Transform> transform = base::nullopt; base::Optional<gfx::Transform> transform = base::nullopt;
if (reference_spaces_.count(space) == 1) { if (reference_spaces_.count(space) == 1) {
transform = GetPose(); if (reference_spaces_.at(space).compare("/reference_space/local") == 0) {
// this locate space call try to get tranform from stage to local which we
// only need to give it identity matrix.
transform = gfx::Transform();
} else if (reference_spaces_.at(space).compare("/reference_space/view") ==
0) {
// this locate space try to locate transform of head pose
transform = GetPose();
} else {
NOTREACHED()
<< "Only locate reference space for local and view are implemented";
}
} else if (action_spaces_.count(space) == 1) { } else if (action_spaces_.count(space) == 1) {
XrAction cur_action = action_spaces_.at(space); XrAction cur_action = action_spaces_.at(space);
ActionProperties cur_action_properties = actions_[cur_action]; ActionProperties cur_action_properties = actions_[cur_action];
......
...@@ -141,7 +141,7 @@ class OpenXrTestHelper : public device::ServiceTestHook { ...@@ -141,7 +141,7 @@ class OpenXrTestHelper : public device::ServiceTestHook {
Microsoft::WRL::ComPtr<ID3D11Device> d3d_device_; Microsoft::WRL::ComPtr<ID3D11Device> d3d_device_;
std::vector<Microsoft::WRL::ComPtr<ID3D11Texture2D>> textures_arr_; std::vector<Microsoft::WRL::ComPtr<ID3D11Texture2D>> textures_arr_;
uint32_t acquired_swapchain_texture_; uint32_t acquired_swapchain_texture_;
uint32_t next_action_space_; uint32_t next_space_;
XrTime next_predicted_display_time_; XrTime next_predicted_display_time_;
// paths_ is used to keep tracked of strings that already has a corresponding // paths_ is used to keep tracked of strings that already has a corresponding
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment