Compare commits

...
27 changed files with 850 additions and 889 deletions
+10 -4
View File
@@ -902,10 +902,16 @@ void application::initialize_vulkan()
pipeline_cache = vk::raii::PipelineCache(vk_device, pipeline_cache_info);
allocator.emplace(VmaAllocatorCreateInfo{
.physicalDevice = *vk_physical_device,
.device = *vk_device,
.instance = *vk_instance,
});
.physicalDevice = *vk_physical_device,
.device = *vk_device,
.instance = *vk_instance,
},
#ifndef NDEBUG
debug_utils_found
#else
false
#endif
);
}
void application::log_views()
+7
View File
@@ -1099,6 +1099,13 @@ ImTextureID imgui_context::load_texture(const std::string & filename)
void imgui_context::free_texture(ImTextureID texture)
{
// Make sure we are done using the texture
std::vector<vk::Fence> fences;
for (auto & f: command_buffers)
fences.push_back(*f.fence);
if (auto result = device.waitForFences(fences, true, 1'000'000'000); result != vk::Result::eSuccess)
spdlog::error("vkWaitForfences: {}", vk::to_string(result));
textures.erase(texture);
}
+9 -31
View File
@@ -28,6 +28,7 @@
#include "vk/allocation.h"
#include "vk/pipeline.h"
#include "vk/shader.h"
#include "vk/specialization_constants.h"
#include <boost/pfr/core.hpp>
#include <entt/entity/entity.hpp>
#include <entt/entt.hpp>
@@ -535,34 +536,11 @@ vk::raii::Pipeline scene_renderer::create_pipeline(const pipeline_info & info)
auto vertex_shader = load_shader(device, info.shader_name + ".vert");
auto fragment_shader = load_shader(device, info.shader_name + ".frag");
std::array specialization_constants_desc{
vk::SpecializationMapEntry{
.constantID = 0,
.offset = offsetof(pipeline_info, nb_texcoords),
.size = sizeof(int32_t),
},
vk::SpecializationMapEntry{
.constantID = 1,
.offset = offsetof(pipeline_info, dithering),
.size = sizeof(VkBool32),
},
vk::SpecializationMapEntry{
.constantID = 2,
.offset = offsetof(pipeline_info, alpha_cutout),
.size = sizeof(VkBool32),
},
vk::SpecializationMapEntry{
.constantID = 3,
.offset = offsetof(pipeline_info, skinning),
.size = sizeof(VkBool32),
}};
vk::SpecializationInfo specialization{
.mapEntryCount = specialization_constants_desc.size(),
.pMapEntries = specialization_constants_desc.data(),
.dataSize = sizeof(pipeline_info),
.pData = &info,
};
auto specialization = make_specialization_constants(
int32_t(info.nb_texcoords),
VkBool32(info.dithering),
VkBool32(info.alpha_cutout),
VkBool32(info.skinning));
return vk::raii::Pipeline{
device,
@@ -573,14 +551,14 @@ vk::raii::Pipeline scene_renderer::create_pipeline(const pipeline_info & info)
.stage = vk::ShaderStageFlagBits::eVertex,
.module = *vertex_shader,
.pName = "main",
.pSpecializationInfo = &specialization,
.pSpecializationInfo = specialization,
},
vk::PipelineShaderStageCreateInfo{
.stage = vk::ShaderStageFlagBits::eFragment,
.module = *fragment_shader,
.pName = "main",
.pSpecializationInfo = &specialization,
.pSpecializationInfo = specialization,
},
},
@@ -797,7 +775,7 @@ void scene_renderer::update_material_descriptor_set(renderer::material & materia
device.updateDescriptorSets(write_ds, {});
}
static void print_scene_hierarchy(const entt::registry & scene, entt::entity root = entt::null, int level = 0)
[[maybe_unused]] static void print_scene_hierarchy(const entt::registry & scene, entt::entity root = entt::null, int level = 0)
{
if (level == 0)
spdlog::info("Node hierarchy:");
+32 -36
View File
@@ -139,46 +139,42 @@ text_rasterizer::text_rasterizer(vk::raii::Device & device, vk::raii::PhysicalDe
image_allocation text_rasterizer::create_image(vk::Extent2D size)
{
image_allocation alloc{device,
vk::ImageCreateInfo{
.imageType = vk::ImageType::e2D,
.format = text::format,
.extent = {
.width = size.width,
.height = size.height,
.depth = 1,
},
.mipLevels = 1,
.arrayLayers = 1,
.samples = vk::SampleCountFlagBits::e1,
.tiling = vk::ImageTiling::eOptimal,
.usage = vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eTransferDst,
.sharingMode = vk::SharingMode::eExclusive,
.initialLayout = vk::ImageLayout::eUndefined,
},
VmaAllocationCreateInfo{
.flags = 0,
.usage = VMA_MEMORY_USAGE_AUTO,
}};
application::set_debug_reports_name<vk::Image>(alloc, "text_rasterizer image");
return alloc;
return {device,
vk::ImageCreateInfo{
.imageType = vk::ImageType::e2D,
.format = text::format,
.extent = {
.width = size.width,
.height = size.height,
.depth = 1,
},
.mipLevels = 1,
.arrayLayers = 1,
.samples = vk::SampleCountFlagBits::e1,
.tiling = vk::ImageTiling::eOptimal,
.usage = vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eTransferDst,
.sharingMode = vk::SharingMode::eExclusive,
.initialLayout = vk::ImageLayout::eUndefined,
},
VmaAllocationCreateInfo{
.flags = 0,
.usage = VMA_MEMORY_USAGE_AUTO,
},
"text_rasterizer image"};
}
buffer_allocation text_rasterizer::create_buffer(size_t size)
{
buffer_allocation alloc{device,
vk::BufferCreateInfo{
.size = size,
.usage = vk::BufferUsageFlagBits::eTransferSrc,
},
VmaAllocationCreateInfo{
.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT,
.usage = VMA_MEMORY_USAGE_AUTO,
}};
application::set_debug_reports_name<vk::Buffer>(alloc, "text_rasterizer buffer");
return alloc;
return {device,
vk::BufferCreateInfo{
.size = size,
.usage = vk::BufferUsageFlagBits::eTransferSrc,
},
VmaAllocationCreateInfo{
.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT,
.usage = VMA_MEMORY_USAGE_AUTO,
},
"text_rasterizer buffer"};
}
text_rasterizer::~text_rasterizer()
+20 -53
View File
@@ -42,6 +42,7 @@
#include "utils/ranges.h"
#include "vk/pipeline.h"
#include "vk/shader.h"
#include "vk/specialization_constants.h"
#include "wivrn_packets.h"
#include <algorithm>
#include <mutex>
@@ -527,7 +528,7 @@ void scenes::stream::push_blit_handle(shard_accumulator * decoder, std::shared_p
}
if (state_ != state::streaming and std::ranges::all_of(decoders, [](accumulator_images & i) {
return i.alpha() or not i.frames().empty();
return i.alpha() or not i.empty();
}))
{
state_ = state::streaming;
@@ -546,15 +547,14 @@ bool scenes::stream::accumulator_images::alpha() const
return decoder->desc().channels == wivrn::to_headset::video_stream_description::channels_t::alpha;
}
std::vector<uint64_t> scenes::stream::accumulator_images::frames() const
bool scenes::stream::accumulator_images::empty() const
{
std::vector<uint64_t> result;
for (const auto & frame: latest_frames)
{
if (frame)
result.push_back(frame->feedback.frame_index);
return false;
}
return result;
return true;
}
std::vector<std::shared_ptr<shard_accumulator::blit_handle>> scenes::stream::common_frame(XrTime display_time)
@@ -805,51 +805,19 @@ void scenes::stream::render(const XrFrameState & frame_state)
const auto & description = i.decoder->desc();
vk::Extent2D image_size = i.decoder->image_size();
std::array useful_size{
float(description.width) / image_size.width,
float(description.height) / image_size.height,
};
spdlog::info("useful size: {}x{} with buffer {}x{}",
description.width,
description.height,
image_size.width,
image_size.height);
std::array specialization_constants_desc{
vk::SpecializationMapEntry{
.constantID = 0,
.offset = 0,
.size = sizeof(float),
},
vk::SpecializationMapEntry{
.constantID = 1,
.offset = sizeof(float),
.size = sizeof(float),
}};
auto vert_constants = make_specialization_constants(
float(description.width) / image_size.width,
float(description.height) / image_size.height);
vk::SpecializationInfo vert_specialization_info;
vert_specialization_info.setMapEntries(specialization_constants_desc);
vert_specialization_info.setData<float>(useful_size);
std::array<VkBool32, 2> constants = {
need_srgb_conversion(guess_model()),
i.alpha(),
};
std::array frag_specialization_constant_desc = {
vk::SpecializationMapEntry{
.constantID = 0,
.offset = 0,
.size = sizeof(constants[0]),
},
vk::SpecializationMapEntry{
.constantID = 1,
.offset = sizeof(constants[0]),
.size = sizeof(constants[1]),
},
};
vk::SpecializationInfo frag_specialization_info;
frag_specialization_info.setMapEntries(frag_specialization_constant_desc);
frag_specialization_info.setData<VkBool32>(constants);
auto frag_constants = make_specialization_constants(
VkBool32(need_srgb_conversion(guess_model())),
VkBool32(i.alpha()));
// Create graphics pipeline
vk::raii::ShaderModule vertex_shader = load_shader(device, "stream.vert");
@@ -867,13 +835,13 @@ void scenes::stream::render(const XrFrameState & frame_state)
.stage = vk::ShaderStageFlagBits::eVertex,
.module = *vertex_shader,
.pName = "main",
.pSpecializationInfo = &vert_specialization_info,
.pSpecializationInfo = vert_constants,
},
{
.stage = vk::ShaderStageFlagBits::eFragment,
.module = *fragment_shader,
.pName = "main",
.pSpecializationInfo = &frag_specialization_info,
.pSpecializationInfo = frag_constants,
}},
.VertexBindingDescriptions = {},
.VertexAttributeDescriptions = {},
@@ -1008,6 +976,10 @@ void scenes::stream::render(const XrFrameState & frame_state)
uint16_t x_offset = 0;
for (auto & out: decoder_output)
{
vk::Extent2D decoder_out_size{
.width = decoder_out_image.info().extent.width,
.height = decoder_out_image.info().extent.height,
};
command_buffer.beginRenderPass(
{
.renderPass = *blit_render_pass,
@@ -1316,10 +1288,7 @@ void scenes::stream::setup(const to_headset::video_stream_description & descript
}
// Create outputs for the decoders
decoder_out_size = vk::Extent2D{video_width, video_height};
{
decoder_out_format = vk::Format::eA8B8G8R8SrgbPack32;
vk::ImageCreateInfo image_info{
.flags = vk::ImageCreateFlags{},
.imageType = vk::ImageType::e2D,
@@ -1343,7 +1312,7 @@ void scenes::stream::setup(const to_headset::video_stream_description & descript
vk::ImageViewCreateInfo image_view_info{
.image = vk::Image{decoder_out_image},
.viewType = vk::ImageViewType::e2D,
.format = vk::Format::eA8B8G8R8SrgbPack32,
.format = image_info.format,
.components = {},
.subresourceRange = {
.aspectMask = vk::ImageAspectFlagBits::eColor,
@@ -1367,8 +1336,8 @@ void scenes::stream::setup(const to_headset::video_stream_description & descript
.renderPass = *blit_render_pass,
.attachmentCount = 1,
.pAttachments = &*output.image_view,
.width = decoder_out_size.width,
.height = decoder_out_size.height,
.width = image_info.extent.width,
.height = image_info.extent.height,
.layers = 1,
});
}
@@ -1435,8 +1404,6 @@ void scenes::stream::setup_reprojection_swapchain(uint32_t swapchain_width, uint
device,
physical_device,
decoder_out_image,
vk::Extent2D{.width = video_width, .height = video_height},
2,
swapchain_images,
extent,
swapchain.format());
+3 -7
View File
@@ -21,7 +21,6 @@
#include "audio/audio.h"
#include "decoder/shard_accumulator.h"
#include "imgui.h"
#include "render/imgui_impl.h"
#include "scene.h"
#include "scenes/input_profile.h"
@@ -68,12 +67,12 @@ private:
vk::DescriptorSet descriptor_set = nullptr;
vk::raii::PipelineLayout blit_pipeline_layout = nullptr;
vk::raii::Pipeline blit_pipeline = nullptr;
// latest frames from oldest to most recent
// latest frames, rolling buffer
std::array<std::shared_ptr<wivrn::shard_accumulator::blit_handle>, image_buffer_size> latest_frames;
std::shared_ptr<wivrn::shard_accumulator::blit_handle> frame(uint64_t id) const;
bool alpha() const;
std::vector<uint64_t> frames() const;
bool empty() const;
};
wifi_lock::wifi wifi;
@@ -85,8 +84,7 @@ private:
std::unique_ptr<wivrn_session> network_session;
std::atomic<bool> exiting = false;
std::thread network_thread;
std::mutex tracking_control_mutex;
to_headset::tracking_control tracking_control{};
thread_safe<to_headset::tracking_control> tracking_control{};
std::array<std::atomic<interaction_profile>, 2> interaction_profiles; // left and right hand
std::atomic<bool> recenter_requested = false;
std::atomic<XrDuration> display_time_phase = 0;
@@ -101,8 +99,6 @@ private:
vk::raii::DescriptorPool blit_descriptor_pool = nullptr;
vk::raii::RenderPass blit_render_pass = nullptr;
vk::Extent2D decoder_out_size;
vk::Format decoder_out_format;
image_allocation decoder_out_image;
struct renderpass_output
+14 -3
View File
@@ -389,8 +389,14 @@ void scenes::stream::gui_performance_metrics()
ImPlot::PopStyleColor(5);
{
std::lock_guard lock(tracking_control_mutex);
ImGui::Text("%s", fmt::format(_F("Estimated motion to photons latency: {}ms"), std::chrono::duration_cast<std::chrono::milliseconds>(tracking_control.max_offset).count()).c_str());
ImGui::Text(
"%s",
fmt::format(
_F("Estimated motion to photons latency: {}ms"),
std::chrono::duration_cast<std::chrono::milliseconds>(
tracking_control.lock()->max_offset)
.count())
.c_str());
if (is_gui_interactable())
ImGui::Text("%s", _S("Press the grip button to move the window"));
@@ -417,7 +423,12 @@ void scenes::stream::gui_compact_view()
f(_S("Upload"), 8 * compact_bandwidth_tx * 1e-6, "Mbit/s");
f(_S("CPU time"), compact_cpu_time * 1000, "ms");
f(_S("GPU time"), compact_gpu_time * 1000, "ms");
f(_S("Motion to photon latency"), std::chrono::duration_cast<std::chrono::microseconds>(tracking_control.max_offset).count() * 1e-3f, "ms");
f(_S("Motion to photon latency"),
std::chrono::duration_cast<std::chrono::microseconds>(
tracking_control.lock()->max_offset)
.count() *
1e-3f,
"ms");
ImGui::EndTable();
}
}
+15 -53
View File
@@ -24,6 +24,7 @@
#include "vk/allocation.h"
#include "vk/pipeline.h"
#include "vk/shader.h"
#include "vk/specialization_constants.h"
#include <array>
#include <glm/glm.hpp>
#include <glm/gtx/quaternion.hpp>
@@ -39,13 +40,6 @@ struct stream_reprojection::vertex
alignas(8) glm::vec2 uv;
};
struct SgsrSpecializationConstants
{
VkBool32 use_edge_direction;
float edge_threshold;
float edge_sharpness;
};
void stream_reprojection::ensure_vertices(size_t num_vertices)
{
vk::BufferCreateInfo create_info{
@@ -74,16 +68,16 @@ stream_reprojection::vertex * stream_reprojection::get_vertices(size_t view)
stream_reprojection::stream_reprojection(
vk::raii::Device & device,
vk::raii::PhysicalDevice & physical_device,
vk::Image input_image_,
vk::Extent2D input_extent,
uint32_t view_count,
image_allocation & input_image,
std::vector<vk::Image> output_images_,
vk::Extent2D output_extent,
vk::Format format) :
view_count(view_count),
view_count(input_image.info().arrayLayers),
device(device),
input_image(input_image_),
input_extent(input_extent),
input_extent{
.width = input_image.info().extent.width,
.height = input_image.info().extent.height,
},
output_images(std::move(output_images_)),
output_extent(output_extent)
{
@@ -144,7 +138,7 @@ stream_reprojection::stream_reprojection(
vk::ImageViewCreateInfo iv_info{
.image = input_image,
.viewType = vk::ImageViewType::e2D,
.format = vk::Format::eA8B8G8R8SrgbPack32,
.format = input_image.info().format,
.components = {
.r = vk::ComponentSwizzle::eIdentity,
.g = vk::ComponentSwizzle::eIdentity,
@@ -223,46 +217,14 @@ stream_reprojection::stream_reprojection(
vk::raii::ShaderModule vertex_shader = load_shader(device, "reprojection.vert");
// Fragment shader
std::string fragment_shader_name = "reprojection.frag";
vk::SpecializationInfo fragment_specialization_info;
SgsrSpecializationConstants fragment_specialization_constants;
std::vector<vk::SpecializationMapEntry> fragment_specialization_constants_desc;
const configuration::sgsr_settings sgsr = application::get_config().sgsr;
if (sgsr.enabled)
{
fragment_shader_name = "reprojection_sgsr.frag";
const configuration::sgsr_settings & sgsr = application::get_config().sgsr;
auto sgsr_specialization = make_specialization_constants(
VkBool32(sgsr.use_edge_direction),
float(sgsr.edge_threshold / 255.f),
float(sgsr.edge_sharpness));
fragment_specialization_constants = {
.use_edge_direction = sgsr.use_edge_direction,
.edge_threshold = float(sgsr.edge_threshold / 255.0),
.edge_sharpness = sgsr.edge_sharpness,
};
fragment_specialization_constants_desc = {
vk::SpecializationMapEntry{
.constantID = 0,
.offset = offsetof(SgsrSpecializationConstants, use_edge_direction),
.size = sizeof(fragment_specialization_constants.use_edge_direction),
},
vk::SpecializationMapEntry{
.constantID = 1,
.offset = offsetof(SgsrSpecializationConstants, edge_threshold),
.size = sizeof(fragment_specialization_constants.edge_threshold),
},
vk::SpecializationMapEntry{
.constantID = 2,
.offset = offsetof(SgsrSpecializationConstants, edge_sharpness),
.size = sizeof(fragment_specialization_constants.edge_sharpness),
},
};
fragment_specialization_info.setMapEntries(fragment_specialization_constants_desc);
fragment_specialization_info.setDataSize(sizeof(fragment_specialization_constants));
fragment_specialization_info.setPData(&fragment_specialization_constants);
}
vk::raii::ShaderModule fragment_shader = load_shader(device, fragment_shader_name);
vk::raii::ShaderModule fragment_shader = load_shader(device, sgsr.enabled ? "reprojection_sgsr.frag" : "reprojection.frag");
// Create graphics pipeline
vk::PipelineLayoutCreateInfo pipeline_layout_info;
@@ -282,7 +244,7 @@ stream_reprojection::stream_reprojection(
.stage = vk::ShaderStageFlagBits::eFragment,
.module = *fragment_shader,
.pName = "main",
.pSpecializationInfo = &fragment_specialization_info,
.pSpecializationInfo = sgsr.enabled ? sgsr_specialization.info() : nullptr,
},
},
.VertexBindingDescriptions = {
+1 -4
View File
@@ -43,7 +43,6 @@ class stream_reprojection
// Source image
vk::raii::Sampler sampler = nullptr;
vk::Image input_image;
std::vector<vk::raii::ImageView> input_image_views;
std::vector<vk::DescriptorSet> descriptor_sets;
vk::Extent2D input_extent;
@@ -61,9 +60,7 @@ public:
stream_reprojection(
vk::raii::Device & device,
vk::raii::PhysicalDevice & physical_device,
vk::Image input_image,
vk::Extent2D input_extent,
uint32_t view_count,
image_allocation & input_image,
std::vector<vk::Image> output_images,
vk::Extent2D output_extent,
vk::Format format);
+4 -8
View File
@@ -433,11 +433,7 @@ void scenes::stream::tracking()
timer t(instance);
int samples = 0;
to_headset::tracking_control control;
{
std::lock_guard lock(tracking_control_mutex);
control = tracking_control;
}
auto control = *tracking_control.lock();
XrDuration prediction = std::clamp<XrDuration>(control.max_offset.count(), 0, 80'000'000);
auto period = std::max<XrDuration>(display_time_period.load(), 1'000'000);
@@ -636,13 +632,13 @@ void scenes::stream::tracking()
void scenes::stream::operator()(to_headset::tracking_control && packet)
{
std::lock_guard lock(tracking_control_mutex);
auto locked = tracking_control.lock();
auto m = size_t(to_headset::tracking_control::id::microphone);
if (audio_handle)
audio_handle->set_mic_state(packet.enabled[m]);
tracking_control = packet;
tracking_control.min_offset = std::min(tracking_control.min_offset, tracking_control.max_offset);
*locked = packet;
locked->min_offset = std::min(locked->min_offset, locked->max_offset);
}
static device_id derived_from(device_id target)
+324 -361
View File
@@ -23,7 +23,6 @@
#include <cairo.h>
#include <fstream>
#include <librsvg/rsvg.h>
#include <limits>
#include <png.h>
#include <span>
#include <unordered_map>
@@ -46,7 +45,7 @@ std::vector<std::byte> load_file(const std::filesystem::path & filename)
template <typename T>
requires std::is_integral_v<T>
T read(std::span<std::byte> & buffer)
T read(std::span<const std::byte> & buffer)
{
if (sizeof(T) > buffer.size())
throw std::runtime_error{"File truncated"};
@@ -65,27 +64,22 @@ T read(std::span<std::byte> & buffer)
template <typename T>
requires std::is_integral_v<T>
std::span<T> read(std::span<std::byte> & buffer, size_t count)
std::span<const T> read(std::span<const std::byte> & buffer, size_t count)
{
if (count * sizeof(T) > buffer.size())
throw std::runtime_error{"File truncated"};
std::span<T> value{reinterpret_cast<T *>(buffer.data()), count};
std::span<const T> value{reinterpret_cast<const T *>(buffer.data()), count};
buffer = buffer.subspan(count * sizeof(T));
return value;
}
std::vector<std::byte> load_svg(const std::filesystem::path & filename, int size)
std::vector<wivrn::icon> try_load_svg(const std::vector<std::byte> & data, int size)
{
// TODO check if aspect ratio needs to be handled, dpi
struct deleter
{
void operator()(GFile * ptr)
{
g_object_unref(ptr);
}
void operator()(RsvgHandle * ptr)
{
g_object_unref(ptr);
@@ -102,15 +96,15 @@ std::vector<std::byte> load_svg(const std::filesystem::path & filename, int size
}
};
using GFile_ptr = std::unique_ptr<GFile, deleter>;
using RsvgHandle_ptr = std::unique_ptr<RsvgHandle, deleter>;
using cairo_surface_t_ptr = std::unique_ptr<cairo_surface_t, deleter>;
using cairo_t_ptr = std::unique_ptr<cairo_t, deleter>;
GError * error{};
GFile_ptr file{g_file_new_for_path(filename.c_str())};
RsvgHandle_ptr handle{rsvg_handle_new_from_gfile_sync(file.get(), RSVG_HANDLE_FLAGS_NONE, nullptr, &error)};
RsvgHandle_ptr handle{rsvg_handle_new_from_data((guint8 *)data.data(), data.size(), &error)};
if (!handle)
throw std::runtime_error{std::string{"Could not open: "} + error->message};
// Create a Cairo image surface and a rendering context for it
cairo_surface_t_ptr surface{cairo_image_surface_create(CAIRO_FORMAT_ARGB32, size, size)};
@@ -145,59 +139,48 @@ std::vector<std::byte> load_svg(const std::filesystem::path & filename, int size
if (auto status = cairo_surface_write_to_png_stream(surface.get(), cb, &png); status != CAIRO_STATUS_SUCCESS)
throw std::runtime_error{std::string{"Could not write output: "} + cairo_status_to_string(status)};
return png;
return {{size, size, 32, std::move(png)}};
}
// See https://gitlab.gnome.org/GNOME/gimp/-/tree/master/plug-ins/file-ico?ref_type=heads
struct ico_file_entry
{
int width; // Width of icon in pixels
int height; // Height of icon in pixels
int bpp; // 1, 4, 8, 16, 24 or 32 bits per pixel
std::span<std::byte> data;
};
constexpr int rowstride(int width, int bpp)
{
int words_per_line = (width * bpp + 31) / 32;
return words_per_line * 4;
}
static_assert(rowstride(1, 1) == 4);
static_assert(rowstride(8, 1) == 4);
static_assert(rowstride(16, 1) == 4);
static_assert(rowstride(32, 1) == 4);
static_assert(rowstride(33, 1) == 8);
static_assert(rowstride(1, 4) == 4);
static_assert(rowstride(8, 4) == 4);
static_assert(rowstride(16, 4) == 8);
static_assert(rowstride(32, 4) == 16);
static_assert(rowstride(33, 4) == 20);
static_assert(rowstride(1, 8) == 4);
static_assert(rowstride(8, 8) == 8);
static_assert(rowstride(16, 8) == 16);
static_assert(rowstride(32, 8) == 32);
static_assert(rowstride(33, 8) == 36);
static_assert(rowstride(1, 24) == 4);
static_assert(rowstride(8, 24) == 24);
static_assert(rowstride(16, 24) == 48);
static_assert(rowstride(32, 24) == 96);
static_assert(rowstride(33, 24) == 100);
static_assert(rowstride(1, 32) == 4);
static_assert(rowstride(8, 32) == 32);
static_assert(rowstride(16, 32) == 64);
static_assert(rowstride(32, 32) == 128);
static_assert(rowstride(33, 32) == 132);
std::vector<std::byte> load_ico(const std::filesystem::path & filename, int size, int index = -1)
std::vector<wivrn::icon> try_load_ico(const std::vector<std::byte> & ico)
{
const uint32_t ICO_PNG_MAGIC = 0x474e5089;
auto ico = load_file(filename);
// See https://gitlab.gnome.org/GNOME/gimp/-/tree/master/plug-ins/file-ico?ref_type=heads
auto rowstride = [](int width, int bpp) {
int words_per_line = (width * bpp + 31) / 32;
return words_per_line * 4;
};
static_assert(rowstride(1, 1) == 4);
static_assert(rowstride(8, 1) == 4);
static_assert(rowstride(16, 1) == 4);
static_assert(rowstride(32, 1) == 4);
static_assert(rowstride(33, 1) == 8);
static_assert(rowstride(1, 4) == 4);
static_assert(rowstride(8, 4) == 4);
static_assert(rowstride(16, 4) == 8);
static_assert(rowstride(32, 4) == 16);
static_assert(rowstride(33, 4) == 20);
static_assert(rowstride(1, 8) == 4);
static_assert(rowstride(8, 8) == 8);
static_assert(rowstride(16, 8) == 16);
static_assert(rowstride(32, 8) == 32);
static_assert(rowstride(33, 8) == 36);
static_assert(rowstride(1, 24) == 4);
static_assert(rowstride(8, 24) == 24);
static_assert(rowstride(16, 24) == 48);
static_assert(rowstride(32, 24) == 96);
static_assert(rowstride(33, 24) == 100);
static_assert(rowstride(1, 32) == 4);
static_assert(rowstride(8, 32) == 32);
static_assert(rowstride(16, 32) == 64);
static_assert(rowstride(32, 32) == 128);
static_assert(rowstride(33, 32) == 132);
std::span header{ico};
@@ -206,358 +189,303 @@ std::vector<std::byte> load_ico(const std::filesystem::path & filename, int size
auto icon_count = read<uint16_t>(header);
if (reserved != 0 or resource_type != 1)
throw std::runtime_error{"Cannot read icon: " + filename.native()};
throw std::runtime_error{"Cannot read icon"};
std::vector<ico_file_entry> entries;
int max_bpp = 0;
std::vector<wivrn::icon> icons;
for (int i = 0; i < icon_count; i++)
{
ico_file_entry entry;
entry.width = read<uint8_t>(header);
entry.height = read<uint8_t>(header);
auto width = read<uint8_t>(header);
auto height = read<uint8_t>(header);
auto num_colors = read<uint8_t>(header);
auto reserved = read<uint8_t>(header); // reserved
auto planes = read<uint16_t>(header);
entry.bpp = read<uint16_t>(header);
auto bpp = read<uint16_t>(header);
auto size = read<uint32_t>(header);
auto offset = read<uint32_t>(header);
if (offset + size > ico.size())
throw std::runtime_error{"Cannot read icon: " + filename.native()};
throw std::runtime_error{"Cannot read icon"};
entry.data = std::span{ico}.subspan(offset, size);
if (entry.width == 0)
entry.width = 256;
if (entry.height == 0)
entry.height = 256;
auto data = std::span{ico}.subspan(offset, size);
if (reserved != 0)
throw std::runtime_error{"Cannot read icon: " + filename.native()};
throw std::runtime_error{"Cannot read icon"};
if (planes != 0 and planes != 1)
throw std::runtime_error{"Cannot read icon: " + filename.native()};
throw std::runtime_error{"Cannot read icon"};
entries.push_back(entry);
auto magic = read<uint32_t>(data);
max_bpp = std::max(max_bpp, entry.bpp);
}
const ico_file_entry * best_entry = index >= 0 ? &entries.at(index) : [&]() {
const ico_file_entry * best_entry = nullptr;
// Look for the smallest multiple of the requested size
int criterion = std::numeric_limits<int>::max();
for (const auto & entry: entries)
if (magic == ICO_PNG_MAGIC)
{
if (entry.bpp != max_bpp)
continue;
// PNG file
std::vector<std::byte> png_data;
if (entry.width % size != 0 or entry.height % size != 0)
continue;
// The PNG magic has already been consumed, put it back
png_data.insert(png_data.end(), data.begin() - 4, data.end());
if (std::min(entry.width, entry.height) / size < criterion)
// Check if the PNG is valid
std::vector<uint8_t> pixels;
png_image png_ref{
.version = PNG_IMAGE_VERSION,
.format = PNG_FORMAT_BGRA,
};
if (not png_image_begin_read_from_memory(&png_ref, png_data.data(), png_data.size()))
continue;
// throw std::runtime_error{"Cannot read icon: " + filename.native()};
pixels.resize(PNG_IMAGE_SIZE(png_ref));
if (!png_image_finish_read(&png_ref, nullptr, pixels.data(), 0, nullptr))
{
criterion = std::min(entry.width, entry.height);
best_entry = &entry;
}
}
if (best_entry)
return best_entry;
// No multiple found: pick the largest icon
criterion = 0;
for (const auto & entry: entries)
{
if (entry.bpp != max_bpp)
png_image_free(&png_ref);
continue;
if (entry.width * entry.height > criterion)
{
criterion = entry.width * entry.height;
best_entry = &entry;
// throw std::runtime_error{"Cannot read icon: " + filename.native()};
}
}
return best_entry;
}();
if (not best_entry)
return {};
auto data = best_entry->data;
auto magic = read<uint32_t>(data);
if (magic == ICO_PNG_MAGIC)
{
// PNG file
std::vector<std::byte> png_data;
// The PNG magic has already been consumed, put it back
png_data.insert(png_data.end(), data.begin() - 4, data.end());
// Check if the PNG is valid
std::vector<uint8_t> pixels;
png_image png_ref{
.version = PNG_IMAGE_VERSION,
.format = PNG_FORMAT_BGRA,
};
if (not png_image_begin_read_from_memory(&png_ref, png_data.data(), png_data.size()))
throw std::runtime_error{"Cannot read icon: " + filename.native()};
pixels.resize(PNG_IMAGE_SIZE(png_ref));
if (!png_image_finish_read(&png_ref, nullptr, pixels.data(), 0, nullptr))
{
// TODO: get bit depth from PNG instead of trusting the ico header
icons.emplace_back(png_ref.width, png_ref.height, bpp, std::move(png_data));
png_image_free(&png_ref);
throw std::runtime_error{"Cannot read icon: " + filename.native()};
}
png_image_free(&png_ref);
return png_data;
}
else if (magic == 40)
{
auto width = read<uint32_t>(data); // Width of image in pixels
auto height = read<uint32_t>(data); // Height of image in pixels
auto planes = read<uint16_t>(data); // Must be 1
auto bpp = read<uint16_t>(data); // 1, 4, 8, 16, 24, 32
auto compression = read<uint32_t>(data); // Must be 0 for icons
auto image_size = read<uint32_t>(data); // Size of image (without this header)
auto x_res = read<uint32_t>(data);
auto y_res = read<uint32_t>(data);
auto used_colors = read<uint32_t>(data);
auto important_colors = read<uint32_t>(data);
if (planes != 1 or compression != 0)
return {};
if (bpp != 1 and
bpp != 4 and
bpp != 8 and
bpp != 16 and
bpp != 24 and
bpp != 32)
return {};
auto w = width;
auto h = height / 2;
std::span<uint8_t> palette; // BGRX
if (bpp <= 16)
else if (magic == 40)
{
// Load the palette
if (used_colors == 0)
used_colors = 1 << bpp;
auto width = read<uint32_t>(data); // Width of image in pixels
auto height = read<uint32_t>(data); // Height of image in pixels
auto planes = read<uint16_t>(data); // Must be 1
auto bpp = read<uint16_t>(data); // 1, 4, 8, 16, 24, 32
auto compression = read<uint32_t>(data); // Must be 0 for icons
auto image_size = read<uint32_t>(data); // Size of image (without this header)
auto x_res = read<uint32_t>(data);
auto y_res = read<uint32_t>(data);
auto used_colors = read<uint32_t>(data);
auto important_colors = read<uint32_t>(data);
palette = read<uint8_t>(data, used_colors * 4);
}
if (planes != 1 or compression != 0)
return {};
size_t xor_stride = rowstride(w, bpp);
size_t and_stride = rowstride(w, 1);
size_t dst_stride = 4 * w;
if (bpp != 1 and
bpp != 4 and
bpp != 8 and
bpp != 16 and
bpp != 24 and
bpp != 32)
return {};
std::span<uint8_t> xor_map = read<uint8_t>(data, xor_stride * h);
std::span<uint8_t> and_map = read<uint8_t>(data, and_stride * h);
auto w = width;
auto h = height / 2;
std::vector<uint8_t> dest_buffer;
dest_buffer.resize(h * dst_stride);
std::span<const uint8_t> palette; // BGRX
switch (bpp)
{
case 1:
for (int y = 0; y < h; y++)
{
uint8_t * src_xor_row = xor_map.data() + xor_stride * y;
uint8_t * src_and_row = and_map.data() + and_stride * y;
uint8_t * dst_row = dest_buffer.data() + dst_stride * (h - 1 - y);
if (bpp <= 16)
{
// Load the palette
if (used_colors == 0)
used_colors = 1 << bpp;
for (int x = 0, i = 0; x < w; x++)
palette = read<uint8_t>(data, used_colors * 4);
}
size_t xor_stride = rowstride(w, bpp);
size_t and_stride = rowstride(w, 1);
size_t dst_stride = 4 * w;
std::span xor_map = read<uint8_t>(data, xor_stride * h);
std::span and_map = read<uint8_t>(data, and_stride * h);
std::vector<uint8_t> dest_buffer;
dest_buffer.resize(h * dst_stride);
switch (bpp)
{
case 1:
for (int y = 0; y < h; y++)
{
int colour = (src_xor_row[x / 8] >> (7 - (x % 8))) & 0x1;
if (colour >= used_colors)
return {};
const uint8_t * src_xor_row = xor_map.data() + xor_stride * y;
const uint8_t * src_and_row = and_map.data() + and_stride * y;
uint8_t * dst_row = dest_buffer.data() + dst_stride * (h - 1 - y);
uint8_t b = palette[4 * colour + 0]; // Blue
uint8_t g = palette[4 * colour + 1]; // Green
uint8_t r = palette[4 * colour + 2]; // Red
for (int x = 0, i = 0; x < w; x++)
{
int colour = (src_xor_row[x / 8] >> (7 - (x % 8))) & 0x1;
if (colour >= used_colors)
return {};
// Get alpha from AND mask (0: opaque => 0xff, 1: transparent => 0)
uint8_t a = src_and_row[x / 8] & (1 << (7 - x % 8)) ? 0 : 0xff;
uint8_t b = palette[4 * colour + 0]; // Blue
uint8_t g = palette[4 * colour + 1]; // Green
uint8_t r = palette[4 * colour + 2]; // Red
*dst_row++ = b;
*dst_row++ = g;
*dst_row++ = r;
*dst_row++ = a;
// Get alpha from AND mask (0: opaque => 0xff, 1: transparent => 0)
uint8_t a = src_and_row[x / 8] & (1 << (7 - x % 8)) ? 0 : 0xff;
*dst_row++ = b;
*dst_row++ = g;
*dst_row++ = r;
*dst_row++ = a;
}
}
}
break;
break;
case 4:
for (int y = 0; y < h; y++)
{
uint8_t * src_xor_row = xor_map.data() + xor_stride * y;
uint8_t * src_and_row = and_map.data() + and_stride * y;
uint8_t * dst_row = dest_buffer.data() + dst_stride * (h - 1 - y);
for (int x = 0, i = 0; x < w; x++)
case 4:
for (int y = 0; y < h; y++)
{
int colour = (src_xor_row[x / 2] >> (4 - 4 * (x % 2))) & 0xf;
if (colour >= used_colors)
return {};
const uint8_t * src_xor_row = xor_map.data() + xor_stride * y;
const uint8_t * src_and_row = and_map.data() + and_stride * y;
uint8_t * dst_row = dest_buffer.data() + dst_stride * (h - 1 - y);
uint8_t b = palette[4 * colour + 0]; // Blue
uint8_t g = palette[4 * colour + 1]; // Green
uint8_t r = palette[4 * colour + 2]; // Red
for (int x = 0, i = 0; x < w; x++)
{
int colour = (src_xor_row[x / 2] >> (4 - 4 * (x % 2))) & 0xf;
if (colour >= used_colors)
return {};
// Get alpha from AND mask (0: opaque => 0xff, 1: transparent => 0)
uint8_t a = src_and_row[x / 8] & (1 << (7 - x % 8)) ? 0 : 0xff;
uint8_t b = palette[4 * colour + 0]; // Blue
uint8_t g = palette[4 * colour + 1]; // Green
uint8_t r = palette[4 * colour + 2]; // Red
*dst_row++ = b;
*dst_row++ = g;
*dst_row++ = r;
*dst_row++ = a;
// Get alpha from AND mask (0: opaque => 0xff, 1: transparent => 0)
uint8_t a = src_and_row[x / 8] & (1 << (7 - x % 8)) ? 0 : 0xff;
*dst_row++ = b;
*dst_row++ = g;
*dst_row++ = r;
*dst_row++ = a;
}
}
}
break;
break;
case 8:
for (int y = 0; y < h; y++)
{
uint8_t * src_xor_row = xor_map.data() + xor_stride * y;
uint8_t * src_and_row = and_map.data() + and_stride * y;
uint8_t * dst_row = dest_buffer.data() + dst_stride * (h - 1 - y);
for (int x = 0, i = 0; x < w; x++)
case 8:
for (int y = 0; y < h; y++)
{
int colour = *src_xor_row++;
if (colour >= used_colors)
return {};
const uint8_t * src_xor_row = xor_map.data() + xor_stride * y;
const uint8_t * src_and_row = and_map.data() + and_stride * y;
uint8_t * dst_row = dest_buffer.data() + dst_stride * (h - 1 - y);
uint8_t b = palette[4 * colour + 0]; // Blue
uint8_t g = palette[4 * colour + 1]; // Green
uint8_t r = palette[4 * colour + 2]; // Red
for (int x = 0, i = 0; x < w; x++)
{
int colour = *src_xor_row++;
if (colour >= used_colors)
return {};
// Get alpha from AND mask (0: opaque => 0xff, 1: transparent => 0)
uint8_t a = src_and_row[x / 8] & (1 << (7 - x % 8)) ? 0 : 0xff;
uint8_t b = palette[4 * colour + 0]; // Blue
uint8_t g = palette[4 * colour + 1]; // Green
uint8_t r = palette[4 * colour + 2]; // Red
*dst_row++ = b;
*dst_row++ = g;
*dst_row++ = r;
*dst_row++ = a;
// Get alpha from AND mask (0: opaque => 0xff, 1: transparent => 0)
uint8_t a = src_and_row[x / 8] & (1 << (7 - x % 8)) ? 0 : 0xff;
*dst_row++ = b;
*dst_row++ = g;
*dst_row++ = r;
*dst_row++ = a;
}
}
}
break;
break;
case 16:
for (int y = 0; y < h; y++)
{
uint8_t * src_xor_row = xor_map.data() + xor_stride * y;
uint8_t * src_and_row = and_map.data() + and_stride * y;
uint8_t * dst_row = dest_buffer.data() + dst_stride * (h - 1 - y);
for (int x = 0, i = 0; x < w; x++)
case 16:
for (int y = 0; y < h; y++)
{
int colour = (src_xor_row[1] << 8) | src_xor_row[0];
src_xor_row += 2;
const uint8_t * src_xor_row = xor_map.data() + xor_stride * y;
const uint8_t * src_and_row = and_map.data() + and_stride * y;
uint8_t * dst_row = dest_buffer.data() + dst_stride * (h - 1 - y);
if (colour >= used_colors)
return {};
for (int x = 0, i = 0; x < w; x++)
{
int colour = (src_xor_row[1] << 8) | src_xor_row[0];
src_xor_row += 2;
uint8_t b = palette[4 * colour + 0]; // Blue
uint8_t g = palette[4 * colour + 1]; // Green
uint8_t r = palette[4 * colour + 2]; // Red
if (colour >= used_colors)
return {};
// Get alpha from AND mask (0: opaque => 0xff, 1: transparent => 0)
uint8_t a = src_and_row[x / 8] & (1 << (7 - x % 8)) ? 0 : 0xff;
uint8_t b = palette[4 * colour + 0]; // Blue
uint8_t g = palette[4 * colour + 1]; // Green
uint8_t r = palette[4 * colour + 2]; // Red
*dst_row++ = b;
*dst_row++ = g;
*dst_row++ = r;
*dst_row++ = a;
// Get alpha from AND mask (0: opaque => 0xff, 1: transparent => 0)
uint8_t a = src_and_row[x / 8] & (1 << (7 - x % 8)) ? 0 : 0xff;
*dst_row++ = b;
*dst_row++ = g;
*dst_row++ = r;
*dst_row++ = a;
}
}
}
break;
break;
case 24:
for (int y = 0; y < h; y++)
{
uint8_t * src_xor_row = xor_map.data() + xor_stride * y;
uint8_t * src_and_row = and_map.data() + and_stride * y;
uint8_t * dst_row = dest_buffer.data() + dst_stride * (h - 1 - y);
for (int x = 0, i = 0; x < w; x++)
case 24:
for (int y = 0; y < h; y++)
{
uint8_t b = *src_xor_row++; // Blue
uint8_t g = *src_xor_row++; // Green
uint8_t r = *src_xor_row++; // Red
const uint8_t * src_xor_row = xor_map.data() + xor_stride * y;
const uint8_t * src_and_row = and_map.data() + and_stride * y;
uint8_t * dst_row = dest_buffer.data() + dst_stride * (h - 1 - y);
// Get alpha from AND mask (0: opaque => 0xff, 1: transparent => 0)
uint8_t a = src_and_row[x / 8] & (1 << (7 - x % 8)) ? 0 : 0xff;
for (int x = 0, i = 0; x < w; x++)
{
uint8_t b = *src_xor_row++; // Blue
uint8_t g = *src_xor_row++; // Green
uint8_t r = *src_xor_row++; // Red
*dst_row++ = b;
*dst_row++ = g;
*dst_row++ = r;
*dst_row++ = a;
// Get alpha from AND mask (0: opaque => 0xff, 1: transparent => 0)
uint8_t a = src_and_row[x / 8] & (1 << (7 - x % 8)) ? 0 : 0xff;
*dst_row++ = b;
*dst_row++ = g;
*dst_row++ = r;
*dst_row++ = a;
}
}
}
break;
break;
case 32:
for (int y = 0; y < h; y++)
{
uint8_t * src_xor_row = (uint8_t *)xor_map.data() + xor_stride * y;
uint8_t * dst_row = dest_buffer.data() + dst_stride * (h - 1 - y);
case 32:
for (int y = 0; y < h; y++)
{
const uint8_t * src_xor_row = xor_map.data() + xor_stride * y;
uint8_t * dst_row = dest_buffer.data() + dst_stride * (h - 1 - y);
memcpy(dst_row, src_xor_row, dst_stride);
}
break;
}
memcpy(dst_row, src_xor_row, dst_stride);
}
break;
}
png_image png{
.version = PNG_IMAGE_VERSION,
.width = w,
.height = h,
.format = PNG_FORMAT_BGRA,
};
png_image png{
.version = PNG_IMAGE_VERSION,
.width = w,
.height = h,
.format = PNG_FORMAT_BGRA,
};
std::vector<std::byte> png_data{65536};
png_alloc_size_t png_size = png_data.size();
png_image_write_to_memory(&png, png_data.data(), &png_size, false /* convert_to_8_bit*/, dest_buffer.data(), w * 4, nullptr);
if (png_size > png_data.size())
{
png_data.resize(png_size);
std::vector<std::byte> png_data{65536};
png_alloc_size_t png_size = png_data.size();
png_image_write_to_memory(&png, png_data.data(), &png_size, false /* convert_to_8_bit*/, dest_buffer.data(), w * 4, nullptr);
}
else
png_data.resize(png_size);
return png_data;
if (png_size > png_data.size())
{
png_data.resize(png_size);
png_image_write_to_memory(&png, png_data.data(), &png_size, false /* convert_to_8_bit*/, dest_buffer.data(), w * 4, nullptr);
}
else
png_data.resize(png_size);
icons.emplace_back(w, h, bpp, std::move(png_data));
}
}
throw std::runtime_error{"Wrong magic number in " + filename.native()};
return icons;
}
std::vector<std::byte> load_zip(const std::filesystem::path & filename, int size)
std::vector<wivrn::icon> try_load_zip(const std::vector<std::byte> & data)
{
std::unique_ptr<archive, decltype(&archive_read_free)> zip{archive_read_new(), &archive_read_free};
archive_read_support_filter_all(zip.get());
archive_read_support_format_all(zip.get());
if (auto rc = archive_read_open_filename(zip.get(), filename.c_str(), 1'000'000); rc != ARCHIVE_OK)
throw std::runtime_error{"Cannot open " + filename.native() + ": " + archive_error_string(zip.get())};
if (auto rc = archive_read_open_memory(zip.get(), data.data(), data.size()); rc != ARCHIVE_OK)
throw std::runtime_error{std::string("Cannot open ZIP: ") + archive_error_string(zip.get())};
archive_entry * entry;
int width = 0;
int height = 0;
std::vector<std::byte> png;
std::vector<wivrn::icon> icons;
while (archive_read_next_header(zip.get(), &entry) == ARCHIVE_OK)
{
printf("%s\n", archive_entry_pathname(entry));
std::vector<std::byte> buffer;
buffer.resize(archive_entry_size(entry));
@@ -577,10 +505,6 @@ std::vector<std::byte> load_zip(const std::filesystem::path & filename, int size
continue;
}
// Keep the largest icon only
if (png_ref.width * png_ref.height < width * height)
continue;
pixels.resize(PNG_IMAGE_SIZE(png_ref));
if (!png_image_finish_read(&png_ref, nullptr, pixels.data(), 0, nullptr))
@@ -589,48 +513,87 @@ std::vector<std::byte> load_zip(const std::filesystem::path & filename, int size
continue;
}
// PNG read successfully: keep it until we find a better one
width = png_ref.width;
height = png_ref.height;
png = std::move(buffer);
// PNG read successfully
icons.emplace_back(png_ref.width, png_ref.height, 32, std::move(buffer)); // TODO: check how to get bit depth
png_image_free(&png_ref);
}
return png;
return icons;
}
std::unordered_map<std::filesystem::path, std::vector<std::byte>> icon_cache;
std::vector<wivrn::icon> try_load_png(const std::vector<std::byte> & png_data)
{
std::vector<wivrn::icon> icons;
// Try reading the PNG
std::vector<uint8_t> pixels;
png_image png_ref{
.version = PNG_IMAGE_VERSION,
.format = PNG_FORMAT_BGRA,
};
if (not png_image_begin_read_from_memory(&png_ref, png_data.data(), png_data.size()))
{
png_image_free(&png_ref);
throw std::runtime_error("");
}
pixels.resize(PNG_IMAGE_SIZE(png_ref));
if (!png_image_finish_read(&png_ref, nullptr, pixels.data(), 0, nullptr))
{
png_image_free(&png_ref);
throw std::runtime_error("");
}
// PNG read successfully
icons.emplace_back(png_ref.width, png_ref.height, 32, std::move(png_data)); // TODO: check how to get bit depth
png_image_free(&png_ref);
return icons;
}
std::unordered_map<std::filesystem::path, std::vector<wivrn::icon>> icon_cache;
} // namespace
const std::vector<std::byte> & wivrn::load_icon(const std::filesystem::path & filename, int size)
const std::vector<wivrn::icon> & wivrn::load_icon(const std::filesystem::path & filename)
{
auto it = icon_cache.find(filename);
if (it != icon_cache.end() and not it->second.empty())
return it->second;
std::vector<std::byte> icon;
auto data = load_file(filename);
if (filename.extension() == ".svg")
try
{
icon = load_svg(filename, size);
}
else if (filename.extension() == ".ico")
{
// Steam icon (Windows)
icon = load_ico(filename, size);
}
else if (filename.extension() == ".zip")
{
// Steam icon (Linux)
icon = load_zip(filename, size);
}
else
{
// TODO read arbitrary format / rewrite as png
icon = load_file(filename);
return icon_cache.emplace(filename, try_load_svg(data, 256)).first->second;
}
catch (...)
{}
return icon_cache.emplace(filename, std::move(icon)).first->second;
try
{
return icon_cache.emplace(filename, try_load_ico(data)).first->second;
}
catch (...)
{}
try
{
return icon_cache.emplace(filename, try_load_zip(data)).first->second;
}
catch (...)
{}
try
{
return icon_cache.emplace(filename, try_load_png(data)).first->second;
}
catch (...)
{}
throw std::runtime_error{"Cannot load icon: " + filename.native()};
}
+10 -2
View File
@@ -23,5 +23,13 @@
namespace wivrn
{
const std::vector<std::byte> & load_icon(const std::filesystem::path & filename, int size);
}
struct icon
{
int width;
int height;
int bpp;
std::vector<std::byte> png_data;
};
const std::vector<icon> & load_icon(const std::filesystem::path & filename);
} // namespace wivrn
+6
View File
@@ -131,6 +131,12 @@ public:
std::tie(resource, allocation) = traits::create(device, create_info, alloc_info);
vmaSetAllocationName(vk_allocator::instance(), allocation, name.c_str());
if (vk_allocator::instance().has_debug_utils)
device.setDebugUtilsObjectNameEXT(vk::DebugUtilsObjectNameInfoEXT{
.objectType = T::objectType,
.objectHandle = uint64_t(CType(*resource)),
.pObjectName = name.c_str(),
});
}
basic_allocation(const basic_allocation &) = delete;
+84
View File
@@ -0,0 +1,84 @@
/*
* WiVRn VR streaming
* Copyright (C) 2025 Patrick Nicolas <patricknicolas@laposte.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <array>
#include <cstdint>
#include <tuple>
#include <vulkan/vulkan.hpp>
template <typename... Args>
class specialization_constants
{
std::tuple<Args...> values;
std::array<vk::SpecializationMapEntry, sizeof...(Args)> entries;
vk::SpecializationInfo info_;
specialization_constants(specialization_constants &&) = delete;
specialization_constants(const specialization_constants &) = delete;
specialization_constants & operator=(const specialization_constants &) = delete;
specialization_constants & operator=(specialization_constants &&) = delete;
template <uint32_t i = sizeof...(Args) - 1>
void fill_entries()
{
entries[i] = vk::SpecializationMapEntry{
.constantID = i,
.offset = uint32_t(uintptr_t(std::addressof(std::get<i>(values))) - uintptr_t(std::addressof(values))),
.size = sizeof(std::get<i>(values)),
};
if constexpr (i > 0)
fill_entries<i - 1>();
}
public:
specialization_constants(Args &&... args) :
values(std::forward<Args>(args)...),
info_{
.mapEntryCount = uint32_t(entries.size()),
.pMapEntries = entries.data(),
.dataSize = sizeof(values),
.pData = &values,
}
{
fill_entries();
}
operator vk::SpecializationInfo *()
{
return &info_;
}
vk::SpecializationInfo * info()
{
return &info_;
}
template <uint32_t i>
auto & data()
{
return std::get<i>(values);
}
};
template <typename... Args>
specialization_constants<Args...> make_specialization_constants(Args &&... args)
{
return specialization_constants<Args...>(std::forward<Args>(args)...);
}
+2 -1
View File
@@ -20,7 +20,8 @@
#include "vk_allocator.h"
#include "vk/check.h"
vk_allocator::vk_allocator(const VmaAllocatorCreateInfo & info)
vk_allocator::vk_allocator(const VmaAllocatorCreateInfo & info, bool has_debug_utils) :
has_debug_utils(has_debug_utils)
{
CHECK_VK(vmaCreateAllocator(&info, &handle));
}
+2 -1
View File
@@ -27,7 +27,8 @@ class vk_allocator : public singleton<vk_allocator>
VmaAllocator handle = nullptr;
public:
vk_allocator(const VmaAllocatorCreateInfo &);
const bool has_debug_utils;
vk_allocator(const VmaAllocatorCreateInfo &, bool has_debug_utils);
~vk_allocator();
operator VmaAllocator()
+33 -33
View File
@@ -10,7 +10,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WiVRn-dashboard\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-08-04 04:40-0300\n"
"POT-Creation-Date: 2025-08-09 22:47+0200\n"
"PO-Revision-Date: 2025-08-08 11:56-0300\n"
"Last-Translator: myghi63 <myghi63@disroot.org>\n"
"Language: pt_BR\n"
@@ -87,7 +87,7 @@ msgid "No precompiled APK is available for this version."
msgstr "Nenhum APK pré-compilado está disponível para esta versão."
#: dashboard/qml/ApkInstallPage.qml:45 dashboard/qml/Main.qml:259
#: dashboard/qml/Main.qml:341
#: dashboard/qml/Main.qml:342
#, kde-format
msgid "ADB is not installed."
msgstr "ADB não está instalado."
@@ -136,7 +136,7 @@ msgstr "Reinstalar WiVRn"
msgid "Install WiVRn"
msgstr "Instalar WiVRn"
#: dashboard/qml/HeadsetsPage.qml:12 dashboard/qml/Main.qml:354
#: dashboard/qml/HeadsetsPage.qml:12 dashboard/qml/Main.qml:355
#, kde-format
msgid "Headsets"
msgstr "Headsets"
@@ -181,7 +181,7 @@ msgstr "Renomear"
#: dashboard/qml/HeadsetsPage.qml:55 dashboard/qml/WizardPage.qml:38
#: dashboard/qml/WizardPage.qml:88 dashboard/qml/WizardPage.qml:263
#: dashboard/qml/WizardPage.qml:326 dashboard/qml/WizardPage.qml:410
#: dashboard/qml/WizardPage.qml:327 dashboard/qml/WizardPage.qml:411
#, kde-format
msgid "Cancel"
msgstr "Cancelar"
@@ -280,8 +280,8 @@ msgid ""
"No OpenVR compatibility detected, Steam games won't be able to load VR.\n"
"Install xrizer or OpenComposite."
msgstr ""
"Nenhuma compatibilidade com OpenVR foi detectada. Os jogos do Steam não conseg"
"uirão carregar em VR.\n"
"Nenhuma compatibilidade com OpenVR foi detectada. Os jogos do Steam não "
"conseguirão carregar em VR.\n"
"Instale o xrizer ou o OpenComposite."
#: dashboard/qml/Main.qml:171
@@ -311,7 +311,7 @@ msgstr "Pareando"
msgid "PIN: %1"
msgstr "PIN: %1"
#: dashboard/qml/Main.qml:250 dashboard/qml/WizardPage.qml:373
#: dashboard/qml/Main.qml:250 dashboard/qml/WizardPage.qml:374
#, kde-format
msgid "Connect by USB"
msgstr "Conectar pela USB"
@@ -338,22 +338,22 @@ msgstr "Aplicativo"
msgid "Steam information"
msgstr "Informações da Steam"
#: dashboard/qml/Main.qml:325
#: dashboard/qml/Main.qml:326
#, kde-format
msgid "Wizard"
msgstr "Assistente"
#: dashboard/qml/Main.qml:332
#: dashboard/qml/Main.qml:333
#, kde-format
msgid "Install the app"
msgstr "Instalar o aplicativo"
#: dashboard/qml/Main.qml:361 dashboard/qml/SettingsPage.qml:14
#: dashboard/qml/Main.qml:362 dashboard/qml/SettingsPage.qml:14
#, kde-format
msgid "Settings"
msgstr "Ajustes"
#: dashboard/qml/Main.qml:368 dashboard/qml/TroubleshootPage.qml:10
#: dashboard/qml/Main.qml:369 dashboard/qml/TroubleshootPage.qml:10
#, kde-format
msgid "Troubleshoot"
msgstr "Resolver problemas"
@@ -645,7 +645,7 @@ msgstr "Comando de lançamento da Steam copiado"
msgid "I cannot find the WiVRn app on my headset"
msgstr "Não consigo encontrar o aplicativo do WiVRn no meu headset"
#: dashboard/qml/TroubleshootPage.qml:21 dashboard/qml/WizardPage.qml:387
#: dashboard/qml/TroubleshootPage.qml:21 dashboard/qml/WizardPage.qml:388
#, kde-format
msgid ""
"If you installed WiVRn over USB on a Meta headset, the app is in the "
@@ -659,7 +659,7 @@ msgstr ""
msgid "I cannot see my computer in the WiVRn app"
msgstr "Não consigo ver meu computador no aplicativo do WiVRn"
#: dashboard/qml/TroubleshootPage.qml:25 dashboard/qml/WizardPage.qml:392
#: dashboard/qml/TroubleshootPage.qml:25 dashboard/qml/WizardPage.qml:393
#, kde-format
msgid ""
"If the server is not visible or the connection fails, check that port 5353 "
@@ -713,7 +713,7 @@ msgstr "Pareamento está atualmente desativado."
msgid "I have no sound on my headset"
msgstr "Eu não tenho som no meu headset"
#: dashboard/qml/TroubleshootPage.qml:50 dashboard/qml/WizardPage.qml:440
#: dashboard/qml/TroubleshootPage.qml:50 dashboard/qml/WizardPage.qml:441
#, kde-format
msgid ""
"When the headset is connected, select \"WiVRn\" as the default audio output "
@@ -738,9 +738,9 @@ msgid "Getting started"
msgstr "Começando"
#: dashboard/qml/WizardPage.qml:29 dashboard/qml/WizardPage.qml:78
#: dashboard/qml/WizardPage.qml:253 dashboard/qml/WizardPage.qml:316
#: dashboard/qml/WizardPage.qml:400 dashboard/qml/WizardPage.qml:447
#: dashboard/qml/WizardPage.qml:484
#: dashboard/qml/WizardPage.qml:253 dashboard/qml/WizardPage.qml:317
#: dashboard/qml/WizardPage.qml:401 dashboard/qml/WizardPage.qml:448
#: dashboard/qml/WizardPage.qml:485
#, kde-format
msgid "Back"
msgstr "Voltar"
@@ -760,8 +760,8 @@ msgstr ""
"ao seu computador."
#: dashboard/qml/WizardPage.qml:83 dashboard/qml/WizardPage.qml:258
#: dashboard/qml/WizardPage.qml:321 dashboard/qml/WizardPage.qml:452
#: dashboard/qml/WizardPage.qml:489
#: dashboard/qml/WizardPage.qml:322 dashboard/qml/WizardPage.qml:453
#: dashboard/qml/WizardPage.qml:490
#, kde-format
msgid "Next"
msgstr "Próximo"
@@ -860,12 +860,12 @@ msgstr ""
"O aplicativo que você escolher será iniciado automaticamente quando você "
"conectar seu headset."
#: dashboard/qml/WizardPage.qml:300
#: dashboard/qml/WizardPage.qml:301
#, kde-format
msgid "Important information"
msgstr "Informação importante"
#: dashboard/qml/WizardPage.qml:307
#: dashboard/qml/WizardPage.qml:308
#, kde-format
msgid ""
"WiVRn entirely replaces SteamVR, you should not start SteamVR while WiVRn is "
@@ -874,12 +874,12 @@ msgstr ""
"O WiVRn substitui o SteamVR completamente, você não deve iniciar o SteamVR "
"enquanto o WiVRn estiver rodando."
#: dashboard/qml/WizardPage.qml:358
#: dashboard/qml/WizardPage.qml:359
#, kde-format
msgid "Start the WiVRn app on your headset"
msgstr "Iniciar o aplicativo do WiVRn no seu headset"
#: dashboard/qml/WizardPage.qml:363
#: dashboard/qml/WizardPage.qml:364
#, kde-format
msgid ""
"To connect over WiFi, start the WiVRn app on your headset, connect to \"%1\" "
@@ -888,32 +888,32 @@ msgstr ""
"Para conectar pelo WiFi, inicie o aplicativo do WiVRn no seu headset, "
"conecte a \"%1\" e entre o PIN \"%2\"."
#: dashboard/qml/WizardPage.qml:370
#: dashboard/qml/WizardPage.qml:371
#, kde-format
msgid "To connect over USB, click on \"Connect by USB\"."
msgstr "Para conectar pela USB, clique em \"Conectar pela USB\"."
#: dashboard/qml/WizardPage.qml:383
#: dashboard/qml/WizardPage.qml:384
#, kde-format
msgid "Troubleshooting"
msgstr "Resolver problemas"
#: dashboard/qml/WizardPage.qml:405
#: dashboard/qml/WizardPage.qml:406
#, kde-format
msgid "Skip"
msgstr "Pular"
#: dashboard/qml/WizardPage.qml:425
#: dashboard/qml/WizardPage.qml:426
#, kde-format
msgid "Connection established"
msgstr "Conexão estabelecida"
#: dashboard/qml/WizardPage.qml:430
#: dashboard/qml/WizardPage.qml:431
#, kde-format
msgid "Your headset is now connected."
msgstr "Seu headset está conectado agora."
#: dashboard/qml/WizardPage.qml:435 dashboard/qml/WizardPage.qml:477
#: dashboard/qml/WizardPage.qml:436 dashboard/qml/WizardPage.qml:478
#, kde-format
msgid ""
"To connect another headset, make sure pairing is enabled in the dashboard "
@@ -922,22 +922,22 @@ msgstr ""
"Para conectar outro headset, se assegure que o pareamento esteja habilitado "
"no painel antes de conectar."
#: dashboard/qml/WizardPage.qml:457 dashboard/qml/WizardPage.qml:494
#: dashboard/qml/WizardPage.qml:458 dashboard/qml/WizardPage.qml:495
#, kde-format
msgid "Finish"
msgstr "Terminar"
#: dashboard/qml/WizardPage.qml:472
#: dashboard/qml/WizardPage.qml:473
#, kde-format
msgid "Finished"
msgstr "Terminado"
#: dashboard/wivrn_server.cpp:584
#: dashboard/wivrn_server.cpp:592
#, kde-format
msgid "xrizer"
msgstr "xrizer"
#: dashboard/wivrn_server.cpp:585
#: dashboard/wivrn_server.cpp:593
#, kde-format
msgid "Open Composite"
msgstr "Open Composite"
+135 -119
View File
@@ -5,20 +5,22 @@
# LuckShiba <LuckShiba@protonmail.com>, 2025.
#
# SPDX-FileCopyrightText: 2025 myghi63 <myghi63@disroot.org>
# Claudio Sampaio <patola@gmail.com>, 2025.
#
msgid ""
msgstr ""
"Project-Id-Version: WiVRn\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-08-04 10:49-0300\n"
"PO-Revision-Date: 2025-08-08 13:27-0300\n"
"Last-Translator: myghi63 <myghi63@disroot.org>\n"
"POT-Creation-Date: 2025-08-16 14:15+0200\n"
"PO-Revision-Date: 2025-08-17 20:58+0200\n"
"Last-Translator: Claudio Sampaio <patola@gmail.com>\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Lokalize 25.04.3\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Gtranslator 48.0\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"Language-Team: Brazilian Portuguese\n"
#: client/scene.cpp:74
msgid "No supported swapchain format"
@@ -47,95 +49,96 @@ msgstr "Incapaz de conectar a {} ({}): {}"
msgid "Waiting for connection"
msgstr "Aguardando conexão"
#: client/scenes/lobby_gui.cpp:229
#: client/scenes/lobby_gui.cpp:230
msgctxt "openxr_post_processing"
msgid "Normal"
msgstr "Normal"
#: client/scenes/lobby_gui.cpp:232
#: client/scenes/lobby_gui.cpp:233
msgctxt "openxr_post_processing"
msgid "Quality"
msgstr "Qualidade"
#: client/scenes/lobby_gui.cpp:234
#: client/scenes/lobby_gui.cpp:235
msgctxt "openxr_post_processing"
msgid "Disabled"
msgstr "Desabilitado"
#: client/scenes/lobby_gui.cpp:242 client/scenes/lobby_gui.cpp:398
#: client/scenes/stream_gui.cpp:812
#: client/scenes/lobby_gui.cpp:243 client/scenes/lobby_gui.cpp:400
#: client/scenes/stream_gui.cpp:825
msgid "Disconnect"
msgstr "Desconectar"
#: client/scenes/lobby_gui.cpp:262 client/scenes/stream_gui.cpp:808
#: client/scenes/lobby_gui.cpp:264 client/scenes/stream_gui.cpp:821
msgid "Close"
msgstr "Fechar"
#: client/scenes/lobby_gui.cpp:268
#: client/scenes/lobby_gui.cpp:270
msgid "Connection"
msgstr "Conexão"
#: client/scenes/lobby_gui.cpp:270
#: client/scenes/lobby_gui.cpp:272
#, c++-format
msgid "Connection to {}"
msgstr "Conexão a {}"
#: client/scenes/lobby_gui.cpp:300
#: client/scenes/lobby_gui.cpp:302
msgid "PIN"
msgstr "PIN"
#: client/scenes/lobby_gui.cpp:322
#: client/scenes/lobby_gui.cpp:324
msgid "Input the PIN displayed on the dashboard"
msgstr "Entre o PIN mostrado no painel"
#: client/scenes/lobby_gui.cpp:393
#: client/scenes/lobby_gui.cpp:395
msgid "Connected to WiVRn server"
msgstr "Conectado ao servidor WiVRn"
#: client/scenes/lobby_gui.cpp:395
#: client/scenes/lobby_gui.cpp:397
#, c++-format
msgid "Connected to {}"
msgstr "Conectado a {}"
#: client/scenes/lobby_gui.cpp:405
#: client/scenes/lobby_gui.cpp:407
msgid "Start an application on the server to start streaming."
msgstr "Abra um aplicativo no servidor para iniciar o streaming."
#: client/scenes/lobby_gui.cpp:414
#: client/scenes/lobby_gui.cpp:419
msgid "Start an application on your computer or select one to start streaming."
msgstr ""
"Abra um aplicativo no seu computador ou selecione um para iniciar o streaming."
"Abra um aplicativo no seu computador ou selecione um para iniciar o "
"streaming."
#: client/scenes/lobby_gui.cpp:416
#: client/scenes/lobby_gui.cpp:421
#, c++-format
msgid "Start an application on {} or select one to start streaming."
msgstr "Abra um aplicativo em {} ou selecione um para iniciar o streaming."
#: client/scenes/lobby_gui.cpp:522
#: client/scenes/lobby_gui.cpp:544
msgid "Name"
msgstr "Nome"
#: client/scenes/lobby_gui.cpp:533
#: client/scenes/lobby_gui.cpp:555
msgid "Address"
msgstr "Endereço"
#: client/scenes/lobby_gui.cpp:542
#: client/scenes/lobby_gui.cpp:564
msgid "Port"
msgstr "Porta"
#: client/scenes/lobby_gui.cpp:550
#: client/scenes/lobby_gui.cpp:572
msgid "TCP only"
msgstr "TCP somente"
#: client/scenes/lobby_gui.cpp:557
#: client/scenes/lobby_gui.cpp:579
msgid "Cancel"
msgstr "Cancelar"
#: client/scenes/lobby_gui.cpp:571
#: client/scenes/lobby_gui.cpp:593
msgid "Save"
msgstr "Salvar"
#: client/scenes/lobby_gui.cpp:624
#: client/scenes/lobby_gui.cpp:646
msgid ""
"Start a WiVRn server on your\n"
"local network"
@@ -143,32 +146,32 @@ msgstr ""
"Inicie um servidor WiVRn em sua\n"
"rede local"
#: client/scenes/lobby_gui.cpp:656
#: client/scenes/lobby_gui.cpp:678
msgid "Autoconnect"
msgstr "Autoconectar"
#: client/scenes/lobby_gui.cpp:682
#: client/scenes/lobby_gui.cpp:704
msgid "Connect"
msgstr "Conectar"
#: client/scenes/lobby_gui.cpp:692 client/wivrn_client.cpp:186
#: client/scenes/lobby_gui.cpp:714 client/wivrn_client.cpp:186
msgid "Incompatible server version"
msgstr "Versão de servidor incompatível"
#: client/scenes/lobby_gui.cpp:694
#: client/scenes/lobby_gui.cpp:716
msgid "Server not available"
msgstr "Servidor não disponível"
#: client/scenes/lobby_gui.cpp:780
#: client/scenes/lobby_gui.cpp:802
msgid "Refresh rate"
msgstr "Taxa de atualização"
#: client/scenes/lobby_gui.cpp:780 client/scenes/lobby_gui.cpp:782
#: client/scenes/lobby_gui.cpp:802 client/scenes/lobby_gui.cpp:804
msgctxt "automatic refresh rate"
msgid "Automatic"
msgstr "Automático"
#: client/scenes/lobby_gui.cpp:789
#: client/scenes/lobby_gui.cpp:811
msgid ""
"Select refresh rate based on measured application performance.\n"
"May cause flicker when a change happens."
@@ -176,60 +179,60 @@ msgstr ""
"Seleciona a taxa de atualização baseada no desempenho medido do aplicativo.\n"
"Pode causar oscilações quando uma alteração ocorrer."
#: client/scenes/lobby_gui.cpp:806
#: client/scenes/lobby_gui.cpp:828
msgid "Minimum refresh rate"
msgstr "Taxa de atualização mínima"
#: client/scenes/lobby_gui.cpp:829
#: client/scenes/lobby_gui.cpp:851
msgid "Resolution scale"
msgstr "Escala de resolução"
#: client/scenes/lobby_gui.cpp:833 client/scenes/lobby_gui.cpp:1072
#: client/scenes/lobby_gui.cpp:855 client/scenes/lobby_gui.cpp:1101
#, c-format, c++-format
msgid "%d%% - {}x{} per eye"
msgstr "%d%% - {}x{} por olho"
#: client/scenes/lobby_gui.cpp:844 client/scenes/lobby_gui.cpp:1083
#: client/scenes/lobby_gui.cpp:866 client/scenes/lobby_gui.cpp:1112
#, c++-format
msgid "Resolution larger than {}x{} may not be supported by the headset"
msgstr "Resolução maior que {}x{} pode não ser suportada pelo headset"
#: client/scenes/lobby_gui.cpp:850
#: client/scenes/lobby_gui.cpp:872
msgid "Enable microphone"
msgstr "Ativar microfone"
#: client/scenes/lobby_gui.cpp:859
#: client/scenes/lobby_gui.cpp:881
msgid "Unprocessed Microphone Audio"
msgstr "Áudio Não-processado de Microfone"
#: client/scenes/lobby_gui.cpp:865
#: client/scenes/lobby_gui.cpp:887
msgid "Force disable audio filters, such as noise cancellation"
msgstr ""
"Força a desativação de filtros de áudio tais como cancelamento de ruído"
#: client/scenes/lobby_gui.cpp:872
#: client/scenes/lobby_gui.cpp:894
msgid "Enable hand tracking"
msgstr "Ativar rastreamento de mãos"
#: client/scenes/lobby_gui.cpp:878 client/scenes/lobby_gui.cpp:890
#: client/scenes/lobby_gui.cpp:902 client/scenes/lobby_gui.cpp:918
#: client/scenes/lobby_gui.cpp:968
#: client/scenes/lobby_gui.cpp:900 client/scenes/lobby_gui.cpp:912
#: client/scenes/lobby_gui.cpp:924 client/scenes/lobby_gui.cpp:940
#: client/scenes/lobby_gui.cpp:990
msgid "This feature is not supported by your headset"
msgstr "Este recurso não é suportado pelo seu headset"
#: client/scenes/lobby_gui.cpp:884
#: client/scenes/lobby_gui.cpp:906
msgid "Enable eye tracking"
msgstr "Ativar rastreamento ocular"
#: client/scenes/lobby_gui.cpp:896
#: client/scenes/lobby_gui.cpp:918
msgid "Enable face tracking"
msgstr "Ativar rastreamento facial"
#: client/scenes/lobby_gui.cpp:909
#: client/scenes/lobby_gui.cpp:931
msgid "Enable body tracking"
msgstr "Ativar rastreamento corporal"
#: client/scenes/lobby_gui.cpp:925
#: client/scenes/lobby_gui.cpp:947
msgid ""
"Requires 'Hand and body tracking' to be enabled in the Quest movement "
"tracking settings,\n"
@@ -241,11 +244,11 @@ msgstr ""
"estimados\n"
"com base nas posições do controle e do headset."
#: client/scenes/lobby_gui.cpp:938
#: client/scenes/lobby_gui.cpp:960
msgid "Enable lower body tracking"
msgstr "Ativar rastreamento corporal inferior"
#: client/scenes/lobby_gui.cpp:944
#: client/scenes/lobby_gui.cpp:966
msgid ""
"Estimate lower body joint positions using Generative Legs\n"
"Requires 'Hand and body tracking' to be enabled in the Quest movement "
@@ -256,11 +259,11 @@ msgstr ""
"Requer que 'Rastreamento corporal e das mãos' esteja ativado nas\n"
"configurações de Rastreamento de Movimento do Quest"
#: client/scenes/lobby_gui.cpp:947
#: client/scenes/lobby_gui.cpp:969
msgid "Enable hip tracking"
msgstr "Ativar rastreamento de quadril"
#: client/scenes/lobby_gui.cpp:953
#: client/scenes/lobby_gui.cpp:975
msgid ""
"Only takes affect with lower body tracking enabled\n"
"May be desired when using another source of hip tracking"
@@ -268,19 +271,32 @@ msgstr ""
"Só tem efeito com o rastreamento corporal inferior ativado\n"
"Pode ser desejado ao usar outra fonte de rastreamento de quadril"
#: client/scenes/lobby_gui.cpp:961
#: client/scenes/lobby_gui.cpp:983
msgid "Enable video passthrough in lobby"
msgstr "Habilitar repassagem de vídeo no lobby"
#: client/scenes/lobby_gui.cpp:982 client/scenes/stream_gui.cpp:434
#: client/scenes/lobby_gui.cpp:994
msgid "Enable in-stream window"
msgstr "Habilitar janela na stream"
#: client/scenes/lobby_gui.cpp:997
msgid ""
"Enables the configuration window to be shown while the game is streaming.\n"
"If enabled, the window is activated by pressing both thumbsticks."
msgstr ""
"Habilita que a janela de configuração seja vista enquanto o jogo está sendo "
"streamado.\n"
"Se habilitado, a janela é ativada clicando os dois joysticks simultaneamente."
#: client/scenes/lobby_gui.cpp:1011 client/scenes/stream_gui.cpp:445
msgid "OpenXR post-processing"
msgstr "Pós-processamento OpenXR"
#: client/scenes/lobby_gui.cpp:986 client/scenes/stream_gui.cpp:438
#: client/scenes/lobby_gui.cpp:1015 client/scenes/stream_gui.cpp:449
msgid "Supersampling"
msgstr "Supersampling"
#: client/scenes/lobby_gui.cpp:1006 client/scenes/stream_gui.cpp:459
#: client/scenes/lobby_gui.cpp:1035 client/scenes/stream_gui.cpp:470
msgid ""
"Reduce flicker for high contrast edges.\n"
"Useful when the input resolution is high compared to the headset display"
@@ -288,11 +304,11 @@ msgstr ""
"Reduz flicker para arestas de alto contraste.\n"
"Útil quando a resolução de entrada é alta comparada ao display do headset"
#: client/scenes/lobby_gui.cpp:1011 client/scenes/stream_gui.cpp:464
#: client/scenes/lobby_gui.cpp:1040 client/scenes/stream_gui.cpp:475
msgid "Sharpening"
msgstr "Aumento de nitidez"
#: client/scenes/lobby_gui.cpp:1031 client/scenes/stream_gui.cpp:485
#: client/scenes/lobby_gui.cpp:1060 client/scenes/stream_gui.cpp:496
msgid ""
"Improve clarity of high contrast edges and counteract blur.\n"
"Useful when the input resolution is low compared to the headset display"
@@ -300,11 +316,11 @@ msgstr ""
"Melhora a clareza de arestas de alto contraste e minimiza o desfoque.\n"
"Útil quando a resolução de entrada é baixa comparada ao display do headset"
#: client/scenes/lobby_gui.cpp:1040
#: client/scenes/lobby_gui.cpp:1069
msgid "Enable Snapdragon Game Super Resolution"
msgstr "Habilitar Snapdragon Game Super Resolution"
#: client/scenes/lobby_gui.cpp:1048
#: client/scenes/lobby_gui.cpp:1077
msgid ""
"On this headset, this setting has been fully superseded by the native "
"Sharpening setting above.\n"
@@ -314,157 +330,157 @@ msgstr ""
"aumento de nitidez acima.\n"
"Somente habilite se souber o que está fazendo."
#: client/scenes/lobby_gui.cpp:1050
#: client/scenes/lobby_gui.cpp:1079
msgid ""
"Client-side upscaling and sharpening, adds a performance cost on the headset"
msgstr ""
"Upscaling e aumento de nitidez do lado do cliente, acrescenta um custo de "
"desempenho no headset"
#: client/scenes/lobby_gui.cpp:1068
#: client/scenes/lobby_gui.cpp:1097
msgid "Upscaling factor"
msgstr "Fator de upscaling"
#: client/scenes/lobby_gui.cpp:1087
#: client/scenes/lobby_gui.cpp:1116
msgid "Use edge direction"
msgstr "Usar direção da aresta"
#: client/scenes/lobby_gui.cpp:1093
#: client/scenes/lobby_gui.cpp:1122
msgid "Adds an additional performance cost"
msgstr "Acrescenta um custo de desempenho"
#: client/scenes/lobby_gui.cpp:1098
#: client/scenes/lobby_gui.cpp:1127
msgid "Edge threshold"
msgstr "Limite da aresta"
#: client/scenes/lobby_gui.cpp:1105 client/scenes/lobby_gui.cpp:1114
#: client/scenes/lobby_gui.cpp:1134 client/scenes/lobby_gui.cpp:1143
#, c++-format
msgid "Recommended: {:.1f}"
msgstr "Recomenadado: {:.1f}"
#: client/scenes/lobby_gui.cpp:1108
#: client/scenes/lobby_gui.cpp:1137
msgid "Edge sharpness"
msgstr "Nitidez da aresta"
#: client/scenes/lobby_gui.cpp:1210 client/scenes/lobby_gui.cpp:1218
#: client/scenes/stream_gui.cpp:222 client/scenes/stream_gui.cpp:418
#: client/scenes/lobby_gui.cpp:1239 client/scenes/lobby_gui.cpp:1247
#: client/scenes/stream_gui.cpp:222 client/scenes/stream_gui.cpp:424
msgid "CPU time"
msgstr "Tempo de CPU"
#: client/scenes/lobby_gui.cpp:1214
#: client/scenes/lobby_gui.cpp:1243
msgid "CPU time [ms]"
msgstr "Tempo de CPU [ms]"
#: client/scenes/lobby_gui.cpp:1224 client/scenes/lobby_gui.cpp:1232
#: client/scenes/stream_gui.cpp:224 client/scenes/stream_gui.cpp:419
#: client/scenes/lobby_gui.cpp:1253 client/scenes/lobby_gui.cpp:1261
#: client/scenes/stream_gui.cpp:224 client/scenes/stream_gui.cpp:425
msgid "GPU time"
msgstr "Tempo de GPU"
#: client/scenes/lobby_gui.cpp:1228
#: client/scenes/lobby_gui.cpp:1257
msgid "GPU time [ms]"
msgstr "Tempo de GPU [ms]"
#: client/scenes/lobby_gui.cpp:1271
#: client/scenes/lobby_gui.cpp:1300
msgid "Enable the microphone?"
msgstr "Habilitar o microfone?"
#: client/scenes/lobby_gui.cpp:1276
#: client/scenes/lobby_gui.cpp:1305
msgid "Enable eye tracking?"
msgstr "Habilitar o rastreamento ocular?"
#: client/scenes/lobby_gui.cpp:1281
#: client/scenes/lobby_gui.cpp:1310
msgid "Enable face tracking?"
msgstr "Habilitar o rastreamento facial?"
#: client/scenes/lobby_gui.cpp:1286
#: client/scenes/lobby_gui.cpp:1315
msgid "Enable body tracking?"
msgstr "Habilitar o rastreamento corporal?"
#: client/scenes/lobby_gui.cpp:1294
#: client/scenes/lobby_gui.cpp:1323
msgid "Welcome to WiVRn"
msgstr "Bem vindo(a) ao WiVRn"
#: client/scenes/lobby_gui.cpp:1318
#: client/scenes/lobby_gui.cpp:1347
msgid "Yes"
msgstr "Sim"
#: client/scenes/lobby_gui.cpp:1325
#: client/scenes/lobby_gui.cpp:1354
msgid "No"
msgstr "Não"
#: client/scenes/lobby_gui.cpp:1344 client/scenes/lobby_gui.cpp:1983
#: client/scenes/lobby_gui.cpp:1373 client/scenes/lobby_gui.cpp:2012
msgid "Licenses"
msgstr "Licenças"
#: client/scenes/lobby_gui.cpp:1658
#: client/scenes/lobby_gui.cpp:1687
msgid "Microphone is enabled"
msgstr "O microfone está ativado"
#: client/scenes/lobby_gui.cpp:1659
#: client/scenes/lobby_gui.cpp:1688
msgid "Microphone is disabled"
msgstr "O microfone está desativado"
#: client/scenes/lobby_gui.cpp:1668
#: client/scenes/lobby_gui.cpp:1697
msgid "Hand tracking is enabled"
msgstr "O rastreamento de mãos está ativado"
#: client/scenes/lobby_gui.cpp:1669
#: client/scenes/lobby_gui.cpp:1698
msgid "Hand tracking is disabled"
msgstr "O rastreamento de mãos está desativado"
#: client/scenes/lobby_gui.cpp:1678
#: client/scenes/lobby_gui.cpp:1707
msgid "Eye tracking is enabled"
msgstr "O rastreamento ocular está ativado"
#: client/scenes/lobby_gui.cpp:1679
#: client/scenes/lobby_gui.cpp:1708
msgid "Eye tracking is disabled"
msgstr "O rastreamento ocular está desativado"
#: client/scenes/lobby_gui.cpp:1692
#: client/scenes/lobby_gui.cpp:1721
msgid "Face tracking is enabled"
msgstr "O rastreamento facial está ativado"
#: client/scenes/lobby_gui.cpp:1693
#: client/scenes/lobby_gui.cpp:1722
msgid "Face tracking is disabled"
msgstr "O rastreamento facial está desativado"
#: client/scenes/lobby_gui.cpp:1703
#: client/scenes/lobby_gui.cpp:1732
msgid "Body tracking is enabled"
msgstr "O rastreamento corporal está ativado"
#: client/scenes/lobby_gui.cpp:1704
#: client/scenes/lobby_gui.cpp:1733
msgid "Body tracking is disabled"
msgstr "O rastreamento corporal está desativado"
#: client/scenes/lobby_gui.cpp:1720
#: client/scenes/lobby_gui.cpp:1749
msgid "Add server"
msgstr "Adicionar servidor"
#: client/scenes/lobby_gui.cpp:1965
#: client/scenes/lobby_gui.cpp:1994
msgid "Server list"
msgstr "Lista de servidores"
#: client/scenes/lobby_gui.cpp:1968 client/scenes/stream_gui.cpp:796
#: client/scenes/lobby_gui.cpp:1997 client/scenes/stream_gui.cpp:809
msgid "Settings"
msgstr "Ajustes"
#: client/scenes/lobby_gui.cpp:1971
#: client/scenes/lobby_gui.cpp:2000
msgid "Post-processing"
msgstr "Pós-processamento"
#: client/scenes/lobby_gui.cpp:1975
#: client/scenes/lobby_gui.cpp:2004
msgid "Debug"
msgstr "Depurar"
#: client/scenes/lobby_gui.cpp:1980
#: client/scenes/lobby_gui.cpp:2009
msgid "About"
msgstr "Sobre"
#: client/scenes/lobby_gui.cpp:1986
#: client/scenes/lobby_gui.cpp:2015
msgid "Exit"
msgstr "Sair"
#: client/scenes/lobby_gui.cpp:2003
#: client/scenes/lobby_gui.cpp:2032
msgid ""
"Press the grip button or put your palm up\n"
"to move the main window"
@@ -472,7 +488,7 @@ msgstr ""
"Pressione o botão de aderência ou coloque a palma da mão para cima\n"
"para mover a janela principal"
#: client/scenes/lobby_gui.cpp:2005
#: client/scenes/lobby_gui.cpp:2034
msgid "Press the grip button to move the main window"
msgstr "Pressione o botão de aderência para mover a janela principal"
@@ -488,11 +504,11 @@ msgstr "Blit"
msgid "Network"
msgstr "Rede"
#: client/scenes/stream_gui.cpp:227 client/scenes/stream_gui.cpp:416
#: client/scenes/stream_gui.cpp:227 client/scenes/stream_gui.cpp:422
msgid "Download"
msgstr "Baixar"
#: client/scenes/stream_gui.cpp:228 client/scenes/stream_gui.cpp:417
#: client/scenes/stream_gui.cpp:228 client/scenes/stream_gui.cpp:423
msgid "Upload"
msgstr "Enviar"
@@ -533,66 +549,66 @@ msgstr "Mostrado"
msgid "Predicted"
msgstr "Previsto"
#: client/scenes/stream_gui.cpp:393
#: client/scenes/stream_gui.cpp:395
#, c++-format
msgid "Estimated motion to photons latency: {}ms"
msgstr "Movimento estimado para a latência de fótons: {}ms"
#: client/scenes/stream_gui.cpp:396
#: client/scenes/stream_gui.cpp:402
msgid "Press the grip button to move the window"
msgstr "Pressione o botão de aderência para mover a janela"
#: client/scenes/stream_gui.cpp:398 client/scenes/stream_gui.cpp:750
#: client/scenes/stream_gui.cpp:404 client/scenes/stream_gui.cpp:763
msgid "Press both thumbsticks to display the WiVRn window"
msgstr "Pressione ambos os thumbsticks para mostrar a janela do WiVRn"
#: client/scenes/stream_gui.cpp:420
#: client/scenes/stream_gui.cpp:426
msgid "Motion to photon latency"
msgstr "Latência (de movimento para fótons)"
#: client/scenes/stream_gui.cpp:492
#: client/scenes/stream_gui.cpp:503
msgid "Foveation center override"
msgstr "Ajuste do centro de foveação"
#: client/scenes/stream_gui.cpp:495
#: client/scenes/stream_gui.cpp:506
msgid "Enable"
msgstr "Habilitar"
#: client/scenes/stream_gui.cpp:503 client/scenes/stream_gui.cpp:550
#: client/scenes/stream_gui.cpp:514 client/scenes/stream_gui.cpp:561
#, c++-format
msgid "Height {:.1f} deg"
msgstr "Altura {:.1f} graus"
#: client/scenes/stream_gui.cpp:504 client/scenes/stream_gui.cpp:551
#: client/scenes/stream_gui.cpp:515 client/scenes/stream_gui.cpp:562
#, c++-format
msgid "Distance {:.2f} m"
msgstr "Distância {:.2f} m"
#: client/scenes/stream_gui.cpp:505
#: client/scenes/stream_gui.cpp:516
msgid "Default"
msgstr "Padrão"
#: client/scenes/stream_gui.cpp:516
#: client/scenes/stream_gui.cpp:527
msgid "Change"
msgstr "Modificar"
#: client/scenes/stream_gui.cpp:548
#: client/scenes/stream_gui.cpp:559
msgid "Use the thumbsticks to move the foveation center"
msgstr "Use os thumbsticks para mover o centro da foveação"
#: client/scenes/stream_gui.cpp:549
#: client/scenes/stream_gui.cpp:560
msgid "Press A to save or B to cancel"
msgstr "Pressione A para salvar ou B para cancelar"
#: client/scenes/stream_gui.cpp:793
#: client/scenes/stream_gui.cpp:806
msgid "Stats"
msgstr "Estatísticas"
#: client/scenes/stream_gui.cpp:802
#: client/scenes/stream_gui.cpp:815
msgid "Statistics overlay"
msgstr "Overlay de estatísticas"
#: client/scenes/stream_gui.cpp:805
#: client/scenes/stream_gui.cpp:818
msgid "Compact view"
msgstr "Visualização compacta"
+5 -2
View File
@@ -232,9 +232,12 @@ static VkResult create_images(struct wivrn_comp_target * cn, vk::ImageUsageFlags
for (uint32_t i = 0; i < cn->image_count; i++)
{
auto & image = cn->psc.images[i].image;
image = image_allocation(device, image_info.get(), {.usage = VMA_MEMORY_USAGE_AUTO});
image = image_allocation(
device,
image_info.get(),
{.usage = VMA_MEMORY_USAGE_AUTO},
std::format("comp target image {}", i));
cn->images[i].handle = image;
cn->wivrn_bundle->name(vk::Image(image), "comp target image");
}
for (uint32_t i = 0; i < cn->image_count; i++)
+75 -74
View File
@@ -37,6 +37,8 @@
namespace wivrn
{
namespace
{
enum wivrn_controller_input_index
{
WIVRN_CONTROLLER_INPUT_INVALID = -1,
@@ -98,7 +100,7 @@ struct input_data
xrt_device_type device;
};
static input_data map_input(device_id id)
input_data map_input(device_id id)
{
switch (id)
{
@@ -247,18 +249,18 @@ static input_data map_input(device_id id)
return {WIVRN_CONTROLLER_INPUT_INVALID, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_UNKNOWN};
}
static xrt_binding_input_pair simple_input_binding[] = {
xrt_binding_input_pair simple_input_binding[] = {
{XRT_INPUT_SIMPLE_SELECT_CLICK, XRT_INPUT_TOUCH_TRIGGER_VALUE},
{XRT_INPUT_SIMPLE_MENU_CLICK, XRT_INPUT_TOUCH_MENU_CLICK},
{XRT_INPUT_SIMPLE_GRIP_POSE, XRT_INPUT_TOUCH_GRIP_POSE},
{XRT_INPUT_SIMPLE_AIM_POSE, XRT_INPUT_TOUCH_AIM_POSE},
};
static xrt_binding_output_pair simple_output_binding[] = {
xrt_binding_output_pair simple_output_binding[] = {
{XRT_OUTPUT_NAME_SIMPLE_VIBRATION, XRT_OUTPUT_NAME_TOUCH_HAPTIC},
};
static xrt_binding_input_pair index_input_binding[] = {
xrt_binding_input_pair index_input_binding[] = {
{XRT_INPUT_INDEX_SYSTEM_CLICK, XRT_INPUT_TOUCH_SYSTEM_CLICK},
{XRT_INPUT_INDEX_SYSTEM_TOUCH, XRT_INPUT_INDEX_SYSTEM_TOUCH},
{XRT_INPUT_INDEX_A_CLICK, XRT_INPUT_TOUCH_A_CLICK},
@@ -280,11 +282,11 @@ static xrt_binding_input_pair index_input_binding[] = {
{XRT_INPUT_INDEX_AIM_POSE, XRT_INPUT_TOUCH_AIM_POSE},
};
static xrt_binding_output_pair index_output_binding[] = {
xrt_binding_output_pair index_output_binding[] = {
{XRT_OUTPUT_NAME_INDEX_HAPTIC, XRT_OUTPUT_NAME_TOUCH_HAPTIC},
};
static xrt_binding_input_pair focus3_input_binding[] = {
xrt_binding_input_pair focus3_input_binding[] = {
{XRT_INPUT_VIVE_FOCUS3_X_CLICK, XRT_INPUT_TOUCH_X_CLICK},
{XRT_INPUT_VIVE_FOCUS3_Y_CLICK, XRT_INPUT_TOUCH_Y_CLICK},
{XRT_INPUT_VIVE_FOCUS3_MENU_CLICK, XRT_INPUT_TOUCH_MENU_CLICK},
@@ -305,11 +307,11 @@ static xrt_binding_input_pair focus3_input_binding[] = {
{XRT_INPUT_VIVE_FOCUS3_AIM_POSE, XRT_INPUT_TOUCH_AIM_POSE},
};
static xrt_binding_output_pair focus3_output_binding[] = {
xrt_binding_output_pair focus3_output_binding[] = {
{XRT_OUTPUT_NAME_VIVE_FOCUS3_HAPTIC, XRT_OUTPUT_NAME_TOUCH_HAPTIC},
};
static xrt_binding_input_pair touch_pro_input_binding[] = {
xrt_binding_input_pair touch_pro_input_binding[] = {
{XRT_INPUT_TOUCH_PRO_X_CLICK, XRT_INPUT_TOUCH_X_CLICK},
{XRT_INPUT_TOUCH_PRO_X_TOUCH, XRT_INPUT_TOUCH_X_TOUCH},
{XRT_INPUT_TOUCH_PRO_Y_CLICK, XRT_INPUT_TOUCH_Y_CLICK},
@@ -337,13 +339,13 @@ static xrt_binding_input_pair touch_pro_input_binding[] = {
{XRT_INPUT_TOUCH_PRO_STYLUS_FORCE, XRT_INPUT_TOUCH_PRO_STYLUS_FORCE},
};
static xrt_binding_output_pair touch_pro_output_binding[] = {
xrt_binding_output_pair touch_pro_output_binding[] = {
{XRT_OUTPUT_NAME_TOUCH_PRO_HAPTIC, XRT_OUTPUT_NAME_TOUCH_HAPTIC},
{XRT_OUTPUT_NAME_TOUCH_PRO_HAPTIC_THUMB, XRT_OUTPUT_NAME_TOUCH_PRO_HAPTIC_THUMB},
{XRT_OUTPUT_NAME_TOUCH_PRO_HAPTIC_TRIGGER, XRT_OUTPUT_NAME_TOUCH_PRO_HAPTIC_TRIGGER},
};
static xrt_binding_input_pair touch_plus_input_binding[] = {
xrt_binding_input_pair touch_plus_input_binding[] = {
{XRT_INPUT_TOUCH_PLUS_X_CLICK, XRT_INPUT_TOUCH_X_CLICK},
{XRT_INPUT_TOUCH_PLUS_X_TOUCH, XRT_INPUT_TOUCH_X_TOUCH},
{XRT_INPUT_TOUCH_PLUS_Y_CLICK, XRT_INPUT_TOUCH_Y_CLICK},
@@ -370,11 +372,11 @@ static xrt_binding_input_pair touch_plus_input_binding[] = {
{XRT_INPUT_TOUCH_PLUS_TRIGGER_SLIDE, XRT_INPUT_TOUCH_PRO_TRIGGER_SLIDE},
};
static xrt_binding_output_pair touch_plus_output_binding[] = {
xrt_binding_output_pair touch_plus_output_binding[] = {
{XRT_OUTPUT_NAME_TOUCH_PLUS_HAPTIC, XRT_OUTPUT_NAME_TOUCH_HAPTIC},
};
static xrt_binding_input_pair pico_neo3_input_binding[] = {
xrt_binding_input_pair pico_neo3_input_binding[] = {
{XRT_INPUT_PICO_NEO3_X_CLICK, XRT_INPUT_TOUCH_X_CLICK},
{XRT_INPUT_PICO_NEO3_X_TOUCH, XRT_INPUT_TOUCH_X_TOUCH},
{XRT_INPUT_PICO_NEO3_Y_CLICK, XRT_INPUT_TOUCH_Y_CLICK},
@@ -397,11 +399,11 @@ static xrt_binding_input_pair pico_neo3_input_binding[] = {
{XRT_INPUT_PICO_NEO3_B_TOUCH, XRT_INPUT_TOUCH_B_TOUCH},
};
static xrt_binding_output_pair pico_neo3_output_binding[] = {
xrt_binding_output_pair pico_neo3_output_binding[] = {
{XRT_OUTPUT_NAME_PICO_NEO3_HAPTIC, XRT_OUTPUT_NAME_TOUCH_HAPTIC},
};
static xrt_binding_input_pair pico4_input_binding[] = {
xrt_binding_input_pair pico4_input_binding[] = {
{XRT_INPUT_PICO4_X_CLICK, XRT_INPUT_TOUCH_X_CLICK},
{XRT_INPUT_PICO4_X_TOUCH, XRT_INPUT_TOUCH_X_TOUCH},
{XRT_INPUT_PICO4_Y_CLICK, XRT_INPUT_TOUCH_Y_CLICK},
@@ -424,11 +426,11 @@ static xrt_binding_input_pair pico4_input_binding[] = {
{XRT_INPUT_PICO4_MENU_CLICK, XRT_INPUT_TOUCH_MENU_CLICK},
};
static xrt_binding_output_pair pico4_output_binding[] = {
xrt_binding_output_pair pico4_output_binding[] = {
{XRT_OUTPUT_NAME_PICO4_HAPTIC, XRT_OUTPUT_NAME_TOUCH_HAPTIC},
};
static xrt_binding_profile wivrn_binding_profiles[] = {
xrt_binding_profile wivrn_binding_profiles[] = {
{
.name = XRT_DEVICE_SIMPLE_CONTROLLER,
.inputs = simple_input_binding,
@@ -480,13 +482,10 @@ static xrt_binding_profile wivrn_binding_profiles[] = {
},
};
namespace
{
struct xrt_space_relation_csv_header
{};
} // namespace
static std::ostream & operator<<(std::ostream & out, const xrt_space_relation_csv_header &)
std::ostream & operator<<(std::ostream & out, const xrt_space_relation_csv_header &)
{
for (auto [value, name]: magic_enum::enum_entries<xrt_space_relation_flags>())
{
@@ -503,44 +502,7 @@ static std::ostream & operator<<(std::ostream & out, const xrt_space_relation_cs
out << "avx,avy,avz";
return out;
}
static std::ostream & operator<<(std::ostream & out, const xrt_space_relation & rel)
{
const auto & pos = rel.pose.position;
const auto & o = rel.pose.orientation;
const auto & v = rel.linear_velocity;
const auto & av = rel.angular_velocity;
for (const auto & [value, name]: magic_enum::enum_entries<xrt_space_relation_flags>())
{
if (value and value != XRT_SPACE_RELATION_BITMASK_ALL)
out << bool(rel.relation_flags & value) << ',';
}
out << pos.x << ',' << pos.y << ',' << pos.z << ',';
out << o.w << ',' << o.x << ',' << o.y << ',' << o.z << ',';
out << v.x << ',' << v.y << ',' << v.z << ',';
out << av.x << ',' << av.y << ',' << av.z;
return out;
}
static std::mutex tracking_dump_mutex;
static std::ofstream & tracking_dump()
{
static auto res = [] {
std::ofstream res;
if (auto wivrn_dump = std::getenv("WIVRN_DUMP_TRACKING"))
{
res.open(wivrn_dump);
res << "device_id,"
"now_ns,"
"timestamp_ns,"
"extrapolation_ns,"
"receive/get,"
<< xrt_space_relation_csv_header{} << std::endl;
}
return res;
}();
return res;
}
} // namespace
wivrn_controller::wivrn_controller(int hand_id,
xrt_device * hmd,
@@ -760,9 +722,8 @@ xrt_result_t wivrn_controller::get_tracked_pose(xrt_input_name name, int64_t at_
return XRT_ERROR_INPUT_UNSUPPORTED;
}
cnx->add_predict_offset(extrapolation_time);
if (auto & out = tracking_dump())
if (auto out = tracking_dump())
{
std::lock_guard lock{tracking_dump_mutex};
auto device = [&] {
switch (name)
{
@@ -773,12 +734,12 @@ xrt_result_t wivrn_controller::get_tracked_pose(xrt_input_name name, int64_t at_
assert(false);
__builtin_unreachable();
} }();
out << magic_enum::enum_name(device) << ','
<< os_monotonic_get_ns() << ','
<< at_timestamp_ns << ','
<< extrapolation_time.count() << ','
<< "g,"
<< *res << std::endl;
*out->lock() << magic_enum::enum_name(device) << ','
<< os_monotonic_get_ns() << ','
<< at_timestamp_ns << ','
<< extrapolation_time.count() << ','
<< "g,"
<< *res << std::endl;
;
}
return XRT_SUCCESS;
@@ -832,19 +793,19 @@ void wivrn_controller::update_tracking(const from_headset::tracking & tracking,
cnx->set_enabled(grip.device, false);
if (not palm.update_tracking(tracking, offset))
cnx->set_enabled(palm.device, false);
if (auto & out = tracking_dump(); out and offset)
if (auto out = tracking_dump(); out and offset)
{
std::lock_guard lock{tracking_dump_mutex};
auto locked = out->lock();
auto now = os_monotonic_get_ns();
for (const auto & pose: tracking.device_poses)
{
if (pose.device == aim.device or pose.device == grip.device or pose.device == palm.device)
out << magic_enum::enum_name(pose.device) << ','
<< now << ','
<< offset.from_headset(tracking.timestamp) << ','
<< tracking.timestamp - tracking.production_timestamp << ','
<< "r,"
<< pose_list::convert_pose(pose) << std::endl;
*locked << magic_enum::enum_name(pose.device) << ','
<< now << ','
<< offset.from_headset(tracking.timestamp) << ','
<< tracking.timestamp - tracking.production_timestamp << ','
<< "r,"
<< pose_list::convert_pose(pose) << std::endl;
}
}
}
@@ -895,4 +856,44 @@ void wivrn_controller::reset_history()
aim.reset();
palm.reset();
}
thread_safe<std::ofstream> * wivrn_controller::tracking_dump()
{
static std::unique_ptr<thread_safe<std::ofstream>> res = [] {
if (auto wivrn_dump = std::getenv("WIVRN_DUMP_TRACKING"))
{
U_LOG_I("Controller tracking dump enabled: %s", wivrn_dump);
std::ofstream res;
res.open(wivrn_dump);
res << "device_id,"
"now_ns,"
"timestamp_ns,"
"extrapolation_ns,"
"receive/get,"
<< xrt_space_relation_csv_header{} << std::endl;
return std::make_unique<thread_safe<std::ofstream>>(std::move(res));
}
return std::unique_ptr<thread_safe<std::ofstream>>();
}();
return res.get();
}
} // namespace wivrn
std::ostream & operator<<(std::ostream & out, const xrt_space_relation & rel)
{
const auto & pos = rel.pose.position;
const auto & o = rel.pose.orientation;
const auto & v = rel.linear_velocity;
const auto & av = rel.angular_velocity;
for (const auto & [value, name]: magic_enum::enum_entries<xrt_space_relation_flags>())
{
if (value and value != XRT_SPACE_RELATION_BITMASK_ALL)
out << bool(rel.relation_flags & value) << ',';
}
out << pos.x << ',' << pos.y << ',' << pos.z << ',';
out << o.w << ',' << o.x << ',' << o.y << ',' << o.z << ',';
out << v.x << ',' << v.y << ',' << v.z << ',';
out << av.x << ',' << av.y << ',' << av.z;
return out;
}
+7
View File
@@ -23,7 +23,9 @@
#include "hand_joints_list.h"
#include "pose_list.h"
#include "utils/thread_safe.h"
#include <fstream>
#include <mutex>
#include <vector>
@@ -64,5 +66,10 @@ public:
void update_hand_tracking(const from_headset::hand_tracking &, const clock_offset &);
void reset_history();
static thread_safe<std::ofstream> * tracking_dump();
};
} // namespace wivrn
std::ostream & operator<<(std::ostream & out, const xrt_space_relation & rel);
-1
View File
@@ -335,7 +335,6 @@ wivrn_foveation::wivrn_foveation(wivrn_vk_bundle & bundle, const xrt_hmd_parts &
.usage = VMA_MEMORY_USAGE_AUTO_PREFER_HOST,
},
"foveation staging buffer");
bundle.name(vk::Buffer(host_buffer), "foveation staging buffer");
}
bundle.name(command_pool, "foveation command pool");
bundle.name(cmd, "foveation command buffer");
+21 -77
View File
@@ -31,13 +31,13 @@
#include <numbers>
#include <optional>
#include <fstream>
#include "xrt/xrt_defines.h"
namespace wivrn
{
namespace
{
enum wivrn_hand_interaction_input_index
{
WIVRN_HAND_INTERACTION_INPUT_INVALID = -1,
@@ -73,7 +73,7 @@ struct input_data
xrt_device_type device;
};
static input_data map_input(device_id id)
input_data map_input(device_id id)
{
switch (id)
{
@@ -134,7 +134,7 @@ static input_data map_input(device_id id)
return {WIVRN_HAND_INTERACTION_INPUT_INVALID, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_UNKNOWN};
}
static xrt_binding_input_pair hand_interaction_input_binding[] = {
xrt_binding_input_pair hand_interaction_input_binding[] = {
{XRT_INPUT_HAND_GRIP_POSE, XRT_INPUT_HAND_GRIP_POSE},
{XRT_INPUT_HAND_AIM_POSE, XRT_INPUT_HAND_AIM_POSE},
{XRT_INPUT_HAND_PINCH_POSE, XRT_INPUT_HAND_PINCH_POSE},
@@ -147,13 +147,13 @@ static xrt_binding_input_pair hand_interaction_input_binding[] = {
{XRT_INPUT_HAND_GRASP_READY, XRT_INPUT_HAND_GRASP_READY},
};
static xrt_binding_input_pair simple_input_binding[] = {
xrt_binding_input_pair simple_input_binding[] = {
{XRT_INPUT_SIMPLE_SELECT_CLICK, XRT_INPUT_HAND_PINCH_VALUE},
{XRT_INPUT_SIMPLE_GRIP_POSE, XRT_INPUT_HAND_GRIP_POSE},
{XRT_INPUT_SIMPLE_AIM_POSE, XRT_INPUT_HAND_AIM_POSE},
};
static xrt_binding_profile wivrn_binding_profiles[] = {
xrt_binding_profile wivrn_binding_profiles[] = {
{
.name = XRT_DEVICE_EXT_HAND_INTERACTION,
.inputs = hand_interaction_input_binding,
@@ -169,63 +169,8 @@ static xrt_binding_profile wivrn_binding_profiles[] = {
.output_count = 0,
},
};
namespace
{
struct xrt_space_relation_csv_header
{};
} // namespace
static std::ostream & operator<<(std::ostream & out, const xrt_space_relation_csv_header &)
{
for (auto [value, name]: magic_enum::enum_entries<xrt_space_relation_flags>())
{
if (value and value != XRT_SPACE_RELATION_BITMASK_ALL)
{
name = name.substr(strlen("XRT_SPACE_RELATION_"));
name = name.substr(0, name.size() - strlen("_BIT"));
out << name << ",";
}
}
out << "x,y,z,";
out << "qw,qx,qy,qz";
return out;
}
static std::ostream & operator<<(std::ostream & out, const xrt_space_relation & rel)
{
const auto & pos = rel.pose.position;
const auto & o = rel.pose.orientation;
for (const auto & [value, name]: magic_enum::enum_entries<xrt_space_relation_flags>())
{
if (value and value != XRT_SPACE_RELATION_BITMASK_ALL)
out << bool(rel.relation_flags & value) << ',';
}
out << pos.x << ',' << pos.y << ',' << pos.z << ',';
out << o.w << ',' << o.x << ',' << o.y << ',' << o.z;
return out;
}
static std::mutex tracking_dump_mutex;
static std::ofstream & tracking_dump()
{
static auto res = [] {
std::ofstream res;
if (auto wivrn_dump = std::getenv("WIVRN_DUMP_TRACKING"))
{
res.open(wivrn_dump);
res << "device_id,"
"now_ns,"
"timestamp_ns,"
"extrapolation_ns,"
"receive/get,"
<< xrt_space_relation_csv_header{} << std::endl;
}
return res;
}();
return res;
}
wivrn_hand_interaction::wivrn_hand_interaction(int hand_id,
xrt_device * hmd,
wivrn::wivrn_session * cnx) :
@@ -410,9 +355,8 @@ xrt_result_t wivrn_hand_interaction::get_tracked_pose(xrt_input_name name, int64
return XRT_ERROR_INPUT_UNSUPPORTED;
}
cnx->add_predict_offset(extrapolation_time);
if (auto & out = tracking_dump())
if (auto out = wivrn_controller::tracking_dump())
{
std::lock_guard lock{tracking_dump_mutex};
auto device = [&] {
switch (name)
{
@@ -425,12 +369,12 @@ xrt_result_t wivrn_hand_interaction::get_tracked_pose(xrt_input_name name, int64
assert(false);
__builtin_unreachable();
} }();
out << magic_enum::enum_name(device) << ','
<< os_monotonic_get_ns() << ','
<< at_timestamp_ns << ','
<< extrapolation_time.count() << ','
<< "g,"
<< *res << std::endl;
*out->lock() << magic_enum::enum_name(device) << ','
<< os_monotonic_get_ns() << ','
<< at_timestamp_ns << ','
<< extrapolation_time.count() << ','
<< "g,"
<< *res << std::endl;
;
}
return XRT_SUCCESS;
@@ -468,19 +412,19 @@ void wivrn_hand_interaction::update_tracking(const from_headset::tracking & trac
cnx->set_enabled(pinch_ext.device, false);
if (not poke_ext.update_tracking(tracking, offset))
cnx->set_enabled(poke_ext.device, false);
if (auto & out = tracking_dump(); out and offset)
if (auto out = wivrn_controller::tracking_dump(); out and offset)
{
std::lock_guard lock{tracking_dump_mutex};
auto now = os_monotonic_get_ns();
auto locked = out->lock();
for (const auto & pose: tracking.device_poses)
{
if (pose.device == aim.device or pose.device == grip.device or pose.device == palm.device)
out << magic_enum::enum_name(pose.device) << ','
<< now << ','
<< offset.from_headset(tracking.timestamp) << ','
<< tracking.timestamp - tracking.production_timestamp << ','
<< "r,"
<< pose_list::convert_pose(pose) << std::endl;
*locked << magic_enum::enum_name(pose.device) << ','
<< now << ','
<< offset.from_headset(tracking.timestamp) << ','
<< tracking.timestamp - tracking.production_timestamp << ','
<< "r,"
<< pose_list::convert_pose(pose) << std::endl;
}
}
}
+13 -2
View File
@@ -761,11 +761,22 @@ void wivrn_session::operator()(from_headset::get_application_list && request)
{
try
{
auto icon = load_icon(*app.icon_path, 256);
const auto & icons = load_icon(*app.icon_path);
if (icons.empty())
continue;
const auto & largest_icon = std::ranges::max(icons, [](const wivrn::icon & a, const wivrn::icon & b) {
if (a.bpp < b.bpp)
return true;
if (a.bpp > b.bpp)
return false;
return a.width * a.height < b.width * b.height;
});
send_control(to_headset::application_icon{
.id = id,
.image = std::move(icon),
.image = largest_icon.png_data,
});
}
catch (std::exception & e)
+8 -8
View File
@@ -176,8 +176,8 @@ void wivrn::video_encoder_vulkan::init(const vk::VideoCapabilitiesKHR & video_ca
img_create_info,
{
.usage = VMA_MEMORY_USAGE_AUTO,
});
vk.name(vk::Image(dpb_image), "vulkan encoder DPB image");
},
"vulkan encoder DPB image");
}
// Output buffer
@@ -195,8 +195,8 @@ void wivrn::video_encoder_vulkan::init(const vk::VideoCapabilitiesKHR & video_ca
{
.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_ALLOW_TRANSFER_INSTEAD_BIT,
.usage = VMA_MEMORY_USAGE_AUTO,
});
vk.name(vk::Buffer(item.output_buffer), "vulkan encode output buffer");
},
"vulkan encode output buffer");
if (not(item.output_buffer.properties() & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT))
{
@@ -208,8 +208,8 @@ void wivrn::video_encoder_vulkan::init(const vk::VideoCapabilitiesKHR & video_ca
{
.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT,
.usage = VMA_MEMORY_USAGE_AUTO,
});
vk.name(vk::Buffer(item.host_buffer), "vulkan encode host buffer");
},
"vulkan encode host buffer");
}
}
@@ -292,8 +292,8 @@ void wivrn::video_encoder_vulkan::init(const vk::VideoCapabilitiesKHR & video_ca
},
{
.usage = VMA_MEMORY_USAGE_AUTO,
});
vk.name(vk::Image(slot_data[i].tmp_image), "vulkan encoder temporary image");
},
"vulkan encoder temporary image");
image_view_template.image = vk::Image(slot_data[i].tmp_image);
slot_data[i].view = vk.device.createImageView(image_view_template);
vk.name(slot_data[i].view, "vulkan encoder temporary image view");
+4 -4
View File
@@ -168,7 +168,8 @@ video_encoder_x264::video_encoder_x264(
{
.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT,
.usage = VMA_MEMORY_USAGE_AUTO,
});
},
"x264 luma buffer");
i.chroma = buffer_allocation(
vk.device, {
.size = vk::DeviceSize(settings.video_width * settings.video_height / 2),
@@ -177,9 +178,8 @@ video_encoder_x264::video_encoder_x264(
{
.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT,
.usage = VMA_MEMORY_USAGE_AUTO,
});
vk.name(vk::Buffer(i.luma), "x264 luma buffer");
vk.name(vk::Buffer(i.chroma), "x264 chroma buffer");
},
"x264 chroma buffer");
auto & pic = i.pic;
x264_picture_init(&pic);
+6 -5
View File
@@ -83,11 +83,12 @@ wivrn::wivrn_vk_bundle::wivrn_vk_bundle(vk_bundle & vk, std::span<const char *>
physical_device(instance, vk.physical_device),
device(physical_device, vk.device),
allocator({
.physicalDevice = vk.physical_device,
.device = vk.device,
.instance = vk.instance,
.vulkanApiVersion = VK_MAKE_VERSION(1, 3, 0), // FIXME: sync with wivrn_session.cpp
}),
.physicalDevice = vk.physical_device,
.device = vk.device,
.instance = vk.instance,
.vulkanApiVersion = VK_MAKE_VERSION(1, 3, 0), // FIXME: sync with wivrn_session.cpp
},
vk.has_EXT_debug_utils),
queue(device, vk.queue_family_index, vk.queue_index),
queue_family_index(vk.queue_family_index),
#ifdef VK_KHR_video_encode_queue