Handle mismatched frames more gracefully
Use pose/fov/foveation from views individually, in case of dropped frames, data may be different per eye
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
#include "vk/shader.h"
|
||||
#include "vk/specialization_constants.h"
|
||||
#include <format>
|
||||
#include <ranges>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
namespace wivrn
|
||||
@@ -198,7 +197,7 @@ void blitter::begin(vk::raii::CommandBuffer & cmd)
|
||||
vk::SubpassContents::eInline);
|
||||
}
|
||||
|
||||
void blitter::push_image(vk::raii::CommandBuffer & cmd, uint8_t stream, vk::Sampler sampler, const vk::Extent2D & extent_, vk::ImageView image, vk::ImageLayout layout)
|
||||
bool blitter::push_image(vk::raii::CommandBuffer & cmd, uint8_t stream, vk::Sampler sampler, const vk::Extent2D & extent_, vk::ImageView image, vk::ImageLayout layout)
|
||||
{
|
||||
if (stream == passthrough_rgb)
|
||||
{
|
||||
@@ -209,7 +208,7 @@ void blitter::push_image(vk::raii::CommandBuffer & cmd, uint8_t stream, vk::Samp
|
||||
extent_.width * desc.items[stream].subsampling,
|
||||
extent_.height * desc.items[stream].subsampling,
|
||||
};
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
if (stream == passthrough_a)
|
||||
{
|
||||
@@ -220,15 +219,15 @@ void blitter::push_image(vk::raii::CommandBuffer & cmd, uint8_t stream, vk::Samp
|
||||
extent_.width * desc.items[stream].subsampling,
|
||||
extent_.height * desc.items[stream].subsampling,
|
||||
};
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (pipelines.empty())
|
||||
return;
|
||||
return false;
|
||||
|
||||
assert(stream < pipelines.size());
|
||||
auto & p = pipelines[stream];
|
||||
if (not p.used)
|
||||
return;
|
||||
return false;
|
||||
|
||||
const auto & extent = target.info().extent;
|
||||
const auto & description = desc.items[stream];
|
||||
@@ -352,6 +351,7 @@ void blitter::push_image(vk::raii::CommandBuffer & cmd, uint8_t stream, vk::Samp
|
||||
.extent = {.width = uint32_t(x1 - x0), .height = uint32_t(y1 - y0)},
|
||||
});
|
||||
cmd.draw(3, 1, 0, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
blitter::output blitter::end(vk::raii::CommandBuffer & cmd)
|
||||
|
||||
@@ -66,7 +66,8 @@ public:
|
||||
|
||||
void reset(const to_headset::video_stream_description & desc);
|
||||
void begin(vk::raii::CommandBuffer &);
|
||||
void push_image(vk::raii::CommandBuffer & buf, uint8_t stream, vk::Sampler sampler, const vk::Extent2D &, vk::ImageView image, vk::ImageLayout);
|
||||
// Return true if the image is used for this blitter's rgb
|
||||
bool push_image(vk::raii::CommandBuffer & buf, uint8_t stream, vk::Sampler sampler, const vk::Extent2D &, vk::ImageView image, vk::ImageLayout);
|
||||
output end(vk::raii::CommandBuffer &);
|
||||
};
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -839,9 +839,9 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
// Search for frame with desired display time on all decoders
|
||||
// If no such frame exists, use the latest frame for each decoder
|
||||
current_blit_handles = common_frame(frame_state.predictedDisplayTime);
|
||||
std::array<XrPosef, 2> pose{};
|
||||
std::array<XrFovf, 2> fov{};
|
||||
std::array<wivrn::to_headset::foveation_parameter, 2> foveation{};
|
||||
std::array<XrPosef, view_count> pose{};
|
||||
std::array<XrFovf, view_count> fov{};
|
||||
std::array<wivrn::to_headset::foveation_parameter, view_count> foveation{};
|
||||
bool use_alpha = false;
|
||||
|
||||
for (auto & blit_handle: current_blit_handles)
|
||||
@@ -855,9 +855,6 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
++blit_handle->feedback.times_displayed;
|
||||
blit_handle->feedback.displayed = frame_state.predictedDisplayTime;
|
||||
|
||||
pose = blit_handle->view_info.pose;
|
||||
fov = blit_handle->view_info.fov;
|
||||
foveation = blit_handle->view_info.foveation;
|
||||
use_alpha = blit_handle->view_info.alpha;
|
||||
|
||||
if (blit_handle->current_layout == vk::ImageLayout::eUndefined)
|
||||
@@ -889,7 +886,12 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
{
|
||||
if (not blit_handle)
|
||||
continue;
|
||||
b.push_image(command_buffer, j, decoders[j].decoder->sampler(), decoders[j].decoder->extent(), blit_handle->image_view, blit_handle->current_layout);
|
||||
if (b.push_image(command_buffer, j, decoders[j].decoder->sampler(), decoders[j].decoder->extent(), blit_handle->image_view, blit_handle->current_layout))
|
||||
{
|
||||
pose[i] = blit_handle->view_info.pose[i];
|
||||
fov[i] = blit_handle->view_info.fov[i];
|
||||
foveation[i] = blit_handle->view_info.foveation[i];
|
||||
}
|
||||
}
|
||||
blitted[i] = b.end(command_buffer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user