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

feat-fix(server_openvr): Add timewarped compositing to Windows OpenVR compositor #2472

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions alvr/server_openvr/cpp/alvr_server/HMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ void Hmd::SetViewsConfig(FfiViewsConfig config) {

this->views_config = config;

// The OpenXR spec defines the HMD position as the midpoint
// between the eyes, so conversion to this is handled by the
// client.
auto left_transform = MATRIX_IDENTITY;
left_transform.m[0][3] = -config.ipd_m / 2.0;
auto right_transform = MATRIX_IDENTITY;
Expand All @@ -318,6 +321,10 @@ void Hmd::SetViewsConfig(FfiViewsConfig config) {

vr::VRServerDriverHost()->SetDisplayProjectionRaw(object_id, left_proj, right_proj);

#ifdef _WIN32
m_directModeComponent->SetViewsConfig(left_proj, left_transform, right_proj, right_transform);
#endif

// todo: check if this is still needed
vr::VRServerDriverHost()->VendorSpecificEvent(
object_id, vr::VREvent_LensDistortionChanged, {}, 0
Expand Down
7 changes: 6 additions & 1 deletion alvr/server_openvr/cpp/platform/win32/CEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ void CEncoder::Initialize(std::shared_ptr<CD3DRender> d3dRender) {
bool CEncoder::CopyToStaging(
ID3D11Texture2D* pTexture[][2],
vr::VRTextureBounds_t bounds[][2],
vr::HmdMatrix34_t poses[],
vr::HmdRect2_t viewProj[2],
vr::HmdMatrix34_t eyeToHead[2],
int layerCount,
bool recentering,
uint64_t presentationTime,
Expand All @@ -91,7 +94,9 @@ bool CEncoder::CopyToStaging(
m_targetTimestampNs = targetTimestampNs;
m_FrameRender->Startup();

m_FrameRender->RenderFrame(pTexture, bounds, layerCount, recentering, message, debugText);
m_FrameRender->RenderFrame(
pTexture, bounds, poses, viewProj, eyeToHead, layerCount, recentering, message, debugText
);
Comment on lines +97 to +99
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also not convinced why the renderer call should be forwarded from the encoder. It doesn't make sense that the renderer is "owned" by the encoder. I don't think this was like that initially but then the linux implementation was made like that and so also the windows impl got changed.
Don't bother fixing this in this PR.

return true;
}

Expand Down
3 changes: 3 additions & 0 deletions alvr/server_openvr/cpp/platform/win32/CEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class CEncoder : public CThread {
bool CopyToStaging(
ID3D11Texture2D* pTexture[][2],
vr::VRTextureBounds_t bounds[][2],
vr::HmdMatrix34_t poses[],
vr::HmdRect2_t viewProj[2],
vr::HmdMatrix34_t eyeToHead[2],
int layerCount,
bool recentering,
uint64_t presentationTime,
Expand Down
Loading
Loading