Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "jnipp.h"
|
||||
|
||||
namespace jni::details
|
||||
{
|
||||
void handle_java_exception()
|
||||
{
|
||||
auto & env = jni_thread::env();
|
||||
if (auto exc = env.ExceptionOccurred())
|
||||
{
|
||||
env.ExceptionClear();
|
||||
|
||||
std::string str = object<"java/lang/Object">{exc}.call<jni::string>("toString");
|
||||
|
||||
throw std::runtime_error("Java exception " + str);
|
||||
}
|
||||
}
|
||||
} // namespace jni::details
|
||||
+40
-4
@@ -25,6 +25,7 @@
|
||||
#include <tuple>
|
||||
|
||||
#include <jni.h>
|
||||
#include <type_traits>
|
||||
|
||||
namespace jni
|
||||
{
|
||||
@@ -171,6 +172,9 @@ struct type_map<int>
|
||||
|
||||
template <typename T>
|
||||
using type_map_t = type_map<T>::type;
|
||||
|
||||
void handle_java_exception();
|
||||
|
||||
} // namespace details
|
||||
|
||||
struct klass
|
||||
@@ -215,7 +219,17 @@ struct klass
|
||||
assert(method_id);
|
||||
auto handles = details::handle(std::forward<Args>(args)...);
|
||||
return R(std::apply([&](auto &... t) {
|
||||
return (env.*R1::call_static_method)(*this, method_id, t...);
|
||||
if constexpr (std::is_void_v<R>)
|
||||
{
|
||||
(env.*R1::call_static_method)(*this, method_id, t...);
|
||||
details::handle_java_exception();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto res = (env.*R1::call_static_method)(*this, method_id, t...);
|
||||
details::handle_java_exception();
|
||||
return res;
|
||||
}
|
||||
},
|
||||
handles));
|
||||
}
|
||||
@@ -283,7 +297,17 @@ struct object
|
||||
assert(method_id);
|
||||
auto handles = details::handle(std::forward<Args>(args)...);
|
||||
return R(std::apply([&](auto &... t) {
|
||||
return (env.*R1::call_method)(*this, method_id, t...);
|
||||
if constexpr (std::is_void_v<R>)
|
||||
{
|
||||
(env.*R1::call_method)(*this, method_id, t...);
|
||||
details::handle_java_exception();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto res = (env.*R1::call_method)(*this, method_id, t...);
|
||||
details::handle_java_exception();
|
||||
return res;
|
||||
}
|
||||
},
|
||||
handles));
|
||||
}
|
||||
@@ -296,7 +320,17 @@ struct object
|
||||
assert(method_id);
|
||||
auto handles = details::handle(std::forward<Args>(args)...);
|
||||
return R(std::apply([&](auto &... t) {
|
||||
return (env.*R1::call_method)(*this, method_id, t...);
|
||||
if constexpr (std::is_void_v<R>)
|
||||
{
|
||||
(env.*R1::call_method)(*this, method_id, t...);
|
||||
details::handle_java_exception();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto res = (env.*R1::call_method)(*this, method_id, t...);
|
||||
details::handle_java_exception();
|
||||
return res;
|
||||
}
|
||||
},
|
||||
handles));
|
||||
}
|
||||
@@ -327,7 +361,9 @@ static object<Type> new_object(Args &&... args)
|
||||
assert(method_id);
|
||||
auto handles = details::handle(std::forward<Args>(args)...);
|
||||
return object<Type>(std::apply([&](auto &... t) {
|
||||
return env.NewObject(klass, method_id, t...);
|
||||
auto res = env.NewObject(klass, method_id, t...);
|
||||
details::handle_java_exception();
|
||||
return res;
|
||||
},
|
||||
handles));
|
||||
}
|
||||
|
||||
+21
-13
@@ -24,6 +24,7 @@
|
||||
#include "scene.h"
|
||||
#include "spdlog/common.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "utils/class_from_member.h"
|
||||
#include "utils/contains.h"
|
||||
#include "utils/files.h"
|
||||
#include "utils/i18n.h"
|
||||
@@ -761,6 +762,7 @@ void application::initialize_vulkan()
|
||||
vk_device_extensions.push_back(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
|
||||
vk_device_extensions.push_back(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME);
|
||||
vk_device_extensions.push_back(VK_KHR_MULTIVIEW_EXTENSION_NAME);
|
||||
optional_device_extensions.emplace(VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME);
|
||||
optional_device_extensions.emplace(VK_IMG_FILTER_CUBIC_EXTENSION_NAME);
|
||||
optional_device_extensions.emplace(VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME);
|
||||
optional_device_extensions.emplace(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
|
||||
@@ -884,24 +886,30 @@ void application::initialize_vulkan()
|
||||
vk::PhysicalDeviceSamplerYcbcrConversionFeaturesKHR{
|
||||
.samplerYcbcrConversion = true,
|
||||
},
|
||||
vk::PhysicalDeviceTimelineSemaphoreFeaturesKHR{
|
||||
.timelineSemaphore = true,
|
||||
},
|
||||
vk::PhysicalDeviceTimelineSemaphoreFeaturesKHR{},
|
||||
vk::PhysicalDeviceMultiviewFeaturesKHR{
|
||||
.multiview = true,
|
||||
},
|
||||
vk::PhysicalDeviceIndexTypeUint8FeaturesEXT{}};
|
||||
|
||||
auto check_feature_flag = [&](auto feature_flag, const char * extension_name) -> bool {
|
||||
using FeatureStruct = class_from_member_t<decltype(feature_flag)>;
|
||||
|
||||
if (utils::contains(vk_device_extensions, extension_name) and
|
||||
vk_physical_device.getFeatures2<vk::PhysicalDeviceFeatures2, FeatureStruct>().template get<FeatureStruct>().*feature_flag)
|
||||
{
|
||||
device_create_info.get<FeatureStruct>().*feature_flag = true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
device_create_info.unlink<FeatureStruct>();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
if (utils::contains(vk_device_extensions, VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME))
|
||||
{
|
||||
auto [_, feat] = vk_physical_device.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceTimelineSemaphoreFeaturesKHR>();
|
||||
auto & create_feat = device_create_info.get<vk::PhysicalDeviceTimelineSemaphoreFeaturesKHR>();
|
||||
create_feat.timelineSemaphore = feat.timelineSemaphore;
|
||||
}
|
||||
else
|
||||
{
|
||||
device_create_info.unlink<vk::PhysicalDeviceTimelineSemaphoreFeaturesKHR>();
|
||||
}
|
||||
check_feature_flag(&vk::PhysicalDeviceTimelineSemaphoreFeaturesKHR::timelineSemaphore, VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME);
|
||||
check_feature_flag(&vk::PhysicalDeviceIndexTypeUint8FeaturesEXT::indexTypeUint8, VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME);
|
||||
|
||||
vk_device = xr_system_id.create_device(vk_physical_device, device_create_info.get());
|
||||
*vk_queue.lock() = vk_device.getQueue(vk_queue_family_index, 0);
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "application.h"
|
||||
#include "utils/alignment.h"
|
||||
#include "utils/contains.h"
|
||||
#include "vk/allocation.h"
|
||||
#include <fastgltf/tools.hpp>
|
||||
#include <fastgltf/types.hpp>
|
||||
@@ -29,6 +31,8 @@ class gpu_buffer
|
||||
{
|
||||
std::vector<std::byte> bytes;
|
||||
vk::PhysicalDeviceLimits limits;
|
||||
vk::PhysicalDeviceIndexTypeUint8FeaturesEXT feat_uint8;
|
||||
|
||||
fastgltf::Asset & asset;
|
||||
vk::BufferUsageFlags usage;
|
||||
|
||||
@@ -58,8 +62,15 @@ class gpu_buffer
|
||||
}
|
||||
|
||||
public:
|
||||
gpu_buffer(vk::PhysicalDeviceProperties properties, fastgltf::Asset & asset) :
|
||||
limits(properties.limits), asset(asset), usage(0) {}
|
||||
gpu_buffer(vk::raii::PhysicalDevice physical_device, fastgltf::Asset & asset) :
|
||||
asset(asset),
|
||||
usage(0)
|
||||
{
|
||||
limits = physical_device.getProperties().limits;
|
||||
|
||||
if (utils::contains(application::instance().get_vk_device_extensions(), VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME))
|
||||
std::tie(std::ignore, feat_uint8) = physical_device.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceIndexTypeUint8FeaturesEXT>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
size_t add_uniform(const T & data_to_add)
|
||||
@@ -79,7 +90,7 @@ public:
|
||||
return add(alignment, data_to_add);
|
||||
}
|
||||
|
||||
size_t add_indices(const fastgltf::Accessor & accessor)
|
||||
std::pair<size_t, vk::IndexType> add_indices(const fastgltf::Accessor & accessor)
|
||||
{
|
||||
usage |= vk::BufferUsageFlagBits::eIndexBuffer;
|
||||
|
||||
@@ -90,7 +101,11 @@ public:
|
||||
std::vector<uint8_t> indices(accessor.count);
|
||||
using index_t = std::remove_cvref_t<decltype(*indices.data())>;
|
||||
fastgltf::copyFromAccessor<index_t>(asset, accessor, indices.data());
|
||||
return add(4, indices);
|
||||
|
||||
if (feat_uint8.indexTypeUint8)
|
||||
return {add(4, indices), vk::IndexType::eUint8EXT};
|
||||
else
|
||||
return {add(4, std::vector<uint16_t>{indices.begin(), indices.end()}), vk::IndexType::eUint16};
|
||||
}
|
||||
|
||||
case fastgltf::ComponentType::Short:
|
||||
@@ -98,7 +113,7 @@ public:
|
||||
std::vector<uint16_t> indices(accessor.count);
|
||||
using index_t = std::remove_cvref_t<decltype(*indices.data())>;
|
||||
fastgltf::copyFromAccessor<index_t>(asset, accessor, indices.data());
|
||||
return add(4, indices);
|
||||
return {add(4, indices), vk::IndexType::eUint16};
|
||||
}
|
||||
|
||||
case fastgltf::ComponentType::Int:
|
||||
@@ -106,7 +121,7 @@ public:
|
||||
std::vector<uint32_t> indices(accessor.count);
|
||||
using index_t = std::remove_cvref_t<decltype(*indices.data())>;
|
||||
fastgltf::copyFromAccessor<index_t>(asset, accessor, indices.data());
|
||||
return add(4, indices);
|
||||
return {add(4, indices), vk::IndexType::eUint32};
|
||||
}
|
||||
|
||||
default:
|
||||
|
||||
@@ -23,13 +23,11 @@
|
||||
#include "utils/thread_safe.h"
|
||||
#include "vk/allocation.h"
|
||||
#include "vk/vk_allocator.h"
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <ktx.h>
|
||||
#include <ktxvulkan.h>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <spdlog/fmt/chrono.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <stdexcept>
|
||||
#include <tuple>
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Guillaume Meunier <guillaume.meunier@centraliens.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/>.
|
||||
*/
|
||||
|
||||
#include "image_writer.h"
|
||||
|
||||
#include "utils/thread_safe.h"
|
||||
#include <cassert>
|
||||
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "stb_image_write.h"
|
||||
|
||||
void write_image(
|
||||
vk::raii::Device & device,
|
||||
thread_safe<vk::raii::Queue> & queue,
|
||||
uint32_t queue_family_index,
|
||||
const std::filesystem::path & path,
|
||||
vk::Image image,
|
||||
const vk::ImageCreateInfo & info)
|
||||
{
|
||||
assert(info.usage & vk::ImageUsageFlagBits::eTransferSrc);
|
||||
assert(info.extent.depth == 1);
|
||||
assert(info.format == vk::Format::eR8G8B8A8Srgb);
|
||||
|
||||
buffer_allocation output_buffer{
|
||||
device,
|
||||
vk::BufferCreateInfo{
|
||||
.size = info.extent.height * info.extent.width * 4,
|
||||
.usage = vk::BufferUsageFlagBits::eTransferDst,
|
||||
},
|
||||
VmaAllocationCreateInfo{
|
||||
.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT,
|
||||
.usage = VmaMemoryUsage::VMA_MEMORY_USAGE_AUTO,
|
||||
},
|
||||
"Saved image buffer"};
|
||||
|
||||
vk::raii::CommandPool cp{
|
||||
device,
|
||||
vk::CommandPoolCreateInfo{
|
||||
.queueFamilyIndex = queue_family_index,
|
||||
}};
|
||||
|
||||
vk::raii::CommandBuffer command_buffer = std::move(device.allocateCommandBuffers(
|
||||
{
|
||||
.commandPool = *cp,
|
||||
.level = vk::CommandBufferLevel::ePrimary,
|
||||
.commandBufferCount = 1,
|
||||
})[0]);
|
||||
|
||||
vk::raii::Fence fence = device.createFence({});
|
||||
|
||||
command_buffer.begin(vk::CommandBufferBeginInfo{});
|
||||
|
||||
command_buffer.pipelineBarrier(
|
||||
vk::PipelineStageFlagBits::eColorAttachmentOutput,
|
||||
vk::PipelineStageFlagBits::eTransfer,
|
||||
vk::DependencyFlags{},
|
||||
{},
|
||||
{},
|
||||
vk::ImageMemoryBarrier{
|
||||
.srcAccessMask = vk::AccessFlagBits::eColorAttachmentWrite,
|
||||
.dstAccessMask = vk::AccessFlagBits::eTransferRead,
|
||||
.oldLayout = vk::ImageLayout::eColorAttachmentOptimal,
|
||||
.newLayout = vk::ImageLayout::eTransferSrcOptimal,
|
||||
.image = image,
|
||||
.subresourceRange = {
|
||||
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||
.baseMipLevel = 0,
|
||||
.levelCount = 1,
|
||||
.baseArrayLayer = 0,
|
||||
.layerCount = 1,
|
||||
},
|
||||
});
|
||||
|
||||
command_buffer.copyImageToBuffer(
|
||||
image,
|
||||
vk::ImageLayout::eTransferSrcOptimal,
|
||||
output_buffer,
|
||||
vk::BufferImageCopy{
|
||||
.bufferOffset = 0,
|
||||
.bufferRowLength = 0,
|
||||
.bufferImageHeight = 0,
|
||||
.imageSubresource = {
|
||||
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||
.mipLevel = 0,
|
||||
.baseArrayLayer = 0,
|
||||
.layerCount = 1,
|
||||
},
|
||||
.imageOffset = {0, 0, 0},
|
||||
.imageExtent = info.extent,
|
||||
});
|
||||
|
||||
command_buffer.end();
|
||||
queue.lock()->submit(vk::SubmitInfo{
|
||||
.commandBufferCount = 1,
|
||||
.pCommandBuffers = &*command_buffer,
|
||||
},
|
||||
*fence);
|
||||
|
||||
if (auto result = device.waitForFences(*fence, true, 1'000'000'000); result == vk::Result::eSuccess)
|
||||
stbi_write_png(path.c_str(), info.extent.width, info.extent.height, 4, output_buffer.data(), 0);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Guillaume Meunier <guillaume.meunier@centraliens.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 "utils/thread_safe.h"
|
||||
#include "vk/allocation.h"
|
||||
#include <filesystem>
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
void write_image(
|
||||
vk::raii::Device & device,
|
||||
thread_safe<vk::raii::Queue> & queue,
|
||||
uint32_t queue_family_index,
|
||||
const std::filesystem::path & path,
|
||||
vk::Image image,
|
||||
const vk::ImageCreateInfo & info);
|
||||
|
||||
inline void write_image(
|
||||
vk::raii::Device & device,
|
||||
thread_safe<vk::raii::Queue> & queue,
|
||||
uint32_t queue_family_index,
|
||||
const std::filesystem::path & path,
|
||||
const image_allocation & image)
|
||||
{
|
||||
write_image(device, queue, queue_family_index, path, (vk::Image)image, image.info());
|
||||
}
|
||||
@@ -55,6 +55,14 @@ struct texture
|
||||
|
||||
struct material
|
||||
{
|
||||
struct alignas(16) texture_info
|
||||
{
|
||||
alignas(4) uint32_t texcoord = 0;
|
||||
alignas(4) float rotation = 0;
|
||||
alignas(8) glm::vec2 offset = {0, 0};
|
||||
alignas(8) glm::vec2 scale = {1, 1};
|
||||
};
|
||||
|
||||
struct gpu_data
|
||||
{
|
||||
glm::vec4 base_color_factor = glm::vec4(1, 1, 1, 1);
|
||||
@@ -65,13 +73,11 @@ struct material
|
||||
float normal_scale = 1;
|
||||
float alpha_cutoff = 0.5;
|
||||
|
||||
uint32_t base_color_texcoord = 0;
|
||||
uint32_t metallic_roughness_texcoord = 0;
|
||||
uint32_t occlusion_texcoord = 0;
|
||||
uint32_t emissive_texcoord = 0;
|
||||
uint32_t normal_texcoord = 0;
|
||||
|
||||
// TODO: add fastgltf::TextureTransform?
|
||||
texture_info base_color;
|
||||
texture_info metallic_roughness;
|
||||
texture_info occlusion;
|
||||
texture_info emissive;
|
||||
texture_info normal;
|
||||
};
|
||||
|
||||
std::shared_ptr<texture> base_color_texture;
|
||||
|
||||
@@ -18,10 +18,12 @@
|
||||
|
||||
#include "scene_loader.h"
|
||||
|
||||
#include "application.h"
|
||||
#include "gpu_buffer.h"
|
||||
#include "image_loader.h"
|
||||
#include "render/scene_components.h"
|
||||
#include "render/vertex_layout.h"
|
||||
#include "utils/contains.h"
|
||||
#include "utils/files.h"
|
||||
#include "utils/json_string.h"
|
||||
#include "utils/mapped_file.h"
|
||||
@@ -166,6 +168,11 @@ glm::vec3 convert(const fastgltf::math::nvec3 & v)
|
||||
return {v[0], v[1], v[2]};
|
||||
}
|
||||
|
||||
glm::vec2 convert(const fastgltf::math::nvec2 & v)
|
||||
{
|
||||
return {v[0], v[1]};
|
||||
}
|
||||
|
||||
components::animation_track_base::interpolation_t convert(fastgltf::AnimationInterpolation interpolation)
|
||||
{
|
||||
switch (interpolation)
|
||||
@@ -441,7 +448,9 @@ struct : std::error_category
|
||||
|
||||
fastgltf::Asset load_gltf_asset(fastgltf::GltfDataBuffer & buffer, const std::filesystem::path & directory)
|
||||
{
|
||||
fastgltf::Parser parser(fastgltf::Extensions::KHR_texture_basisu);
|
||||
fastgltf::Parser parser(
|
||||
fastgltf::Extensions::KHR_texture_basisu |
|
||||
fastgltf::Extensions::KHR_texture_transform);
|
||||
|
||||
auto gltf_options =
|
||||
fastgltf::Options::DontRequireValidAssetMember |
|
||||
@@ -750,37 +759,37 @@ public:
|
||||
material_data.roughness_factor = gltf_material.pbrData.roughnessFactor;
|
||||
material_data.alpha_cutoff = gltf_material.alphaCutoff;
|
||||
|
||||
if (gltf_material.pbrData.baseColorTexture)
|
||||
{
|
||||
material.base_color_texture = textures.at(gltf_material.pbrData.baseColorTexture->textureIndex);
|
||||
material_data.base_color_texcoord = gltf_material.pbrData.baseColorTexture->texCoordIndex;
|
||||
}
|
||||
auto f = [&](const auto & texture_info,
|
||||
std::shared_ptr<renderer::texture> & texture,
|
||||
renderer::material::texture_info & info) {
|
||||
if (not texture_info)
|
||||
return;
|
||||
|
||||
if (gltf_material.pbrData.metallicRoughnessTexture)
|
||||
{
|
||||
material.metallic_roughness_texture = textures.at(gltf_material.pbrData.metallicRoughnessTexture->textureIndex);
|
||||
material_data.metallic_roughness_texcoord = gltf_material.pbrData.metallicRoughnessTexture->texCoordIndex;
|
||||
}
|
||||
texture = textures.at(texture_info->textureIndex);
|
||||
info.texcoord = texture_info->texCoordIndex;
|
||||
|
||||
if (auto & xform = texture_info->transform)
|
||||
{
|
||||
if (xform->texCoordIndex)
|
||||
info.texcoord = *xform->texCoordIndex;
|
||||
|
||||
info.rotation = xform->rotation;
|
||||
info.offset = convert(xform->uvOffset);
|
||||
info.scale = convert(xform->uvScale);
|
||||
}
|
||||
};
|
||||
|
||||
f(gltf_material.pbrData.baseColorTexture, material.base_color_texture, material_data.base_color);
|
||||
f(gltf_material.pbrData.metallicRoughnessTexture, material.metallic_roughness_texture, material_data.metallic_roughness);
|
||||
f(gltf_material.occlusionTexture, material.occlusion_texture, material_data.occlusion);
|
||||
f(gltf_material.emissiveTexture, material.emissive_texture, material_data.emissive);
|
||||
f(gltf_material.normalTexture, material.normal_texture, material_data.normal);
|
||||
|
||||
if (gltf_material.occlusionTexture)
|
||||
{
|
||||
material.occlusion_texture = textures.at(gltf_material.occlusionTexture->textureIndex);
|
||||
material_data.occlusion_texcoord = gltf_material.occlusionTexture->texCoordIndex;
|
||||
material_data.occlusion_strength = gltf_material.occlusionTexture->strength;
|
||||
}
|
||||
|
||||
if (gltf_material.emissiveTexture)
|
||||
{
|
||||
material.emissive_texture = textures.at(gltf_material.emissiveTexture->textureIndex);
|
||||
material_data.emissive_texcoord = gltf_material.emissiveTexture->texCoordIndex;
|
||||
}
|
||||
|
||||
if (gltf_material.normalTexture)
|
||||
{
|
||||
material.normal_texture = textures.at(gltf_material.normalTexture->textureIndex);
|
||||
material_data.normal_texcoord = gltf_material.normalTexture->texCoordIndex;
|
||||
material_data.normal_scale = gltf_material.normalTexture->scale;
|
||||
}
|
||||
|
||||
material.offset = staging_buffer.add_uniform(material_data);
|
||||
}
|
||||
@@ -808,30 +817,8 @@ public:
|
||||
fastgltf::Accessor & indices_accessor = gltf.accessors.at(*gltf_primitive.indicesAccessor);
|
||||
|
||||
primitive_ref.indexed = true;
|
||||
primitive_ref.index_offset = staging_buffer.add_indices(indices_accessor);
|
||||
std::tie(primitive_ref.index_offset, primitive_ref.index_type) = staging_buffer.add_indices(indices_accessor);
|
||||
primitive_ref.index_count = indices_accessor.count;
|
||||
|
||||
switch (indices_accessor.componentType)
|
||||
{
|
||||
case fastgltf::ComponentType::Byte:
|
||||
case fastgltf::ComponentType::UnsignedByte:
|
||||
primitive_ref.index_type = vk::IndexType::eUint8EXT;
|
||||
break;
|
||||
|
||||
case fastgltf::ComponentType::Short:
|
||||
case fastgltf::ComponentType::UnsignedShort:
|
||||
primitive_ref.index_type = vk::IndexType::eUint16;
|
||||
break;
|
||||
|
||||
case fastgltf::ComponentType::Int:
|
||||
case fastgltf::ComponentType::UnsignedInt:
|
||||
primitive_ref.index_type = vk::IndexType::eUint32;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw std::runtime_error("Invalid index type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
primitive_ref.indexed = false;
|
||||
@@ -1089,8 +1076,6 @@ std::shared_ptr<entt::registry> scene_loader::operator()(
|
||||
const std::filesystem::path & gltf_texture_cache,
|
||||
std::function<void(float)> progress_cb)
|
||||
{
|
||||
vk::PhysicalDeviceProperties physical_device_properties = physical_device.getProperties();
|
||||
|
||||
auto data_buffer = fastgltf::GltfDataBuffer::FromBytes(data.data(), data.size());
|
||||
if (auto error = data_buffer.error(); error != fastgltf::Error::None)
|
||||
throw std::system_error((int)error, fastgltf_error_category);
|
||||
@@ -1108,7 +1093,7 @@ std::shared_ptr<entt::registry> scene_loader::operator()(
|
||||
// Load all buffers from URIs
|
||||
ctx.load_all_buffers();
|
||||
|
||||
gpu_buffer staging_buffer(physical_device_properties, asset);
|
||||
gpu_buffer staging_buffer(physical_device, asset);
|
||||
|
||||
// Load all textures
|
||||
auto textures = ctx.load_all_textures(gltf_texture_cache, progress_cb);
|
||||
|
||||
@@ -138,7 +138,7 @@ std::shared_ptr<renderer::texture> scene_renderer::create_default_texture(image_
|
||||
return std::make_shared<renderer::texture>(image_view, renderer::sampler_info{});
|
||||
}
|
||||
|
||||
std::shared_ptr<renderer::material> scene_renderer::create_default_material(vk::raii::CommandPool & cb_pool)
|
||||
std::shared_ptr<renderer::material> scene_renderer::create_default_material()
|
||||
{
|
||||
image_loader loader(device, physical_device, queue, queue_family_index);
|
||||
|
||||
@@ -261,7 +261,7 @@ static std::array layout_bindings_0{
|
||||
.binding = 8,
|
||||
.descriptorType = vk::DescriptorType::eUniformBuffer,
|
||||
.descriptorCount = 1,
|
||||
.stageFlags = vk::ShaderStageFlagBits::eFragment,
|
||||
.stageFlags = vk::ShaderStageFlagBits::eVertex | vk::ShaderStageFlagBits::eFragment,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -285,7 +285,7 @@ scene_renderer::scene_renderer(
|
||||
layout_0(create_descriptor_set_layout(layout_bindings_0, vk::DescriptorSetLayoutCreateFlagBits::ePushDescriptorKHR))
|
||||
{
|
||||
// Create the default material
|
||||
default_material = create_default_material(cb_pool);
|
||||
default_material = create_default_material();
|
||||
|
||||
// Create Vulkan resources
|
||||
frame_resources.resize(frames_in_flight);
|
||||
|
||||
@@ -148,7 +148,7 @@ class scene_renderer
|
||||
vk::raii::Pipeline create_pipeline(const pipeline_info & info);
|
||||
|
||||
std::shared_ptr<renderer::texture> create_default_texture(image_loader & loader, std::vector<uint8_t> pixel, const std::string & name);
|
||||
std::shared_ptr<renderer::material> create_default_material(vk::raii::CommandPool & cb_pool);
|
||||
std::shared_ptr<renderer::material> create_default_material();
|
||||
vk::raii::DescriptorSetLayout create_descriptor_set_layout(std::span<vk::DescriptorSetLayoutBinding> bindings, vk::DescriptorSetLayoutCreateFlags flags = {});
|
||||
|
||||
// Caches
|
||||
|
||||
@@ -26,12 +26,18 @@
|
||||
#include "imgui.h"
|
||||
#include "imgui_internal.h"
|
||||
#include "imspinner.h"
|
||||
#include "render/image_writer.h"
|
||||
#include "render/scene_renderer.h"
|
||||
#include "utils/files.h"
|
||||
#include "utils/i18n.h"
|
||||
#include "utils/json_string.h"
|
||||
#include "vk/allocation.h"
|
||||
#include <algorithm>
|
||||
#include <boost/url/url.hpp>
|
||||
#include <boost/url/url_view.hpp>
|
||||
#include <chrono>
|
||||
#include <spdlog/fmt/chrono.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#include "IconsFontAwesome6.h"
|
||||
|
||||
@@ -53,8 +59,12 @@ void scenes::lobby::save_environment_json()
|
||||
<< ",\"description\":" << json_string(model.description)
|
||||
<< ",\"screenshot\":" << json_string(model.screenshot_url)
|
||||
<< ",\"url\":" << json_string(model.gltf_url)
|
||||
<< ",\"size\":" << model.size
|
||||
<< "},";
|
||||
<< ",\"size\":" << model.size;
|
||||
|
||||
// TODO only if not the default value
|
||||
ss << ",\"local_screenshot\":" << json_string(model.local_screenshot_path);
|
||||
ss << ",\"local_path\":" << json_string(model.local_gltf_path);
|
||||
ss << "},";
|
||||
}
|
||||
if (not empty)
|
||||
ss.seekp(-1, ss.cur);
|
||||
@@ -112,8 +122,16 @@ std::vector<scenes::lobby::environment_model> scenes::lobby::load_environment_js
|
||||
model.size = val.get_int64();
|
||||
|
||||
model.builtin = false;
|
||||
model.local_screenshot_path = application::get_config_path() / "environments" / (model.name + ".png");
|
||||
model.local_gltf_path = application::get_config_path() / "environments" / (model.name + ".glb");
|
||||
|
||||
if (auto val = i["local_screenshot"]; val.is_string())
|
||||
model.local_screenshot_path = val.get_string().value();
|
||||
else
|
||||
model.local_screenshot_path = application::get_config_path() / "environments" / (model.name + ".png");
|
||||
|
||||
if (auto val = i["local_path"]; val.is_string())
|
||||
model.local_gltf_path = val.get_string().value();
|
||||
else
|
||||
model.local_gltf_path = application::get_config_path() / "environments" / (model.name + ".glb");
|
||||
|
||||
models.push_back(std::move(model));
|
||||
}
|
||||
@@ -180,24 +198,102 @@ void scenes::lobby::update_file_picker()
|
||||
load_environment_status = "";
|
||||
future_environment = utils::async<std::pair<std::string, std::shared_ptr<entt::registry>>, float>(
|
||||
[this](auto token, file_picker_result environment) {
|
||||
auto local_path = application::get_cache_path() / "local.glb";
|
||||
auto t = std::chrono::system_clock::now();
|
||||
auto local_path = application::get_cache_path() / fmt::format("local-{:%F-%T}.glb", t);
|
||||
auto local_screenshot_path = application::get_cache_path() / fmt::format("local-{:%F-%T}.png", t);
|
||||
|
||||
utils::write_whole_file(local_path, (std::span<const std::byte>)environment.file);
|
||||
|
||||
// TODO remove only local.glb from cache
|
||||
clear_gltf_cache();
|
||||
environment_model model{
|
||||
.name = _S("Locally loaded environment"),
|
||||
.author = "",
|
||||
.description = "",
|
||||
.screenshot_url = "",
|
||||
.gltf_url = fmt::format("local-{:%F-%T}", t), // Used as key
|
||||
.size = environment.file.size(),
|
||||
.local_screenshot_path = local_screenshot_path,
|
||||
.local_gltf_path = local_path,
|
||||
};
|
||||
|
||||
return std::make_pair(
|
||||
local_path,
|
||||
load_gltf(local_path, [&](float progress) {
|
||||
token.set_progress(progress);
|
||||
}));
|
||||
int n = 2;
|
||||
while (std::ranges::find(local_environments, model.name, &environment_model::name) != local_environments.end())
|
||||
{
|
||||
model.name = fmt::format(_F("Locally loaded environment ({})"), n++);
|
||||
}
|
||||
|
||||
local_environments.push_back(model);
|
||||
std::ranges::sort(local_environments, std::less{});
|
||||
save_environment_json();
|
||||
|
||||
std::shared_ptr<entt::registry> env = load_gltf(local_path, [&](float progress) { token.set_progress(progress); });
|
||||
|
||||
// Create a screenshot of the loaded environment
|
||||
scene_renderer::frame_info frame{
|
||||
.projection = projection_matrix(
|
||||
XrFovf{
|
||||
.angleLeft = -0.7,
|
||||
.angleRight = 0.7,
|
||||
.angleUp = 0.7,
|
||||
.angleDown = -0.7,
|
||||
},
|
||||
constants::lobby::near_plane),
|
||||
.view = view_matrix(XrPosef{
|
||||
.orientation = {0, 0, 0, 1},
|
||||
.position = {0, 1.6, 0},
|
||||
})};
|
||||
|
||||
image_allocation output{
|
||||
device,
|
||||
vk::ImageCreateInfo{
|
||||
.imageType = vk::ImageType::e2D,
|
||||
.format = vk::Format::eR8G8B8A8Srgb,
|
||||
.extent = {512, 512, 1},
|
||||
.mipLevels = 1,
|
||||
.arrayLayers = 1,
|
||||
.usage = vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eTransferSrc,
|
||||
},
|
||||
VmaAllocationCreateInfo{
|
||||
.usage = VmaMemoryUsage::VMA_MEMORY_USAGE_AUTO,
|
||||
},
|
||||
"Screenshot image",
|
||||
};
|
||||
|
||||
scene_renderer local_renderer{device, physical_device, queue, queue_family_index};
|
||||
local_renderer.start_frame();
|
||||
local_renderer.render(
|
||||
*env,
|
||||
{
|
||||
constants::lobby::sky_color.r,
|
||||
constants::lobby::sky_color.g,
|
||||
constants::lobby::sky_color.b,
|
||||
constants::lobby::sky_color.a,
|
||||
},
|
||||
layer_lobby,
|
||||
vk::Extent2D{
|
||||
output.info().extent.width,
|
||||
output.info().extent.height,
|
||||
|
||||
}, // Output size
|
||||
output.info().format, // Output format
|
||||
vk::Format::eD32Sfloat, // Depth format
|
||||
output, // Output image
|
||||
vk::Image{}, // Depth image
|
||||
vk::Image{}, // Foveation image
|
||||
{&frame, 1}, // View info
|
||||
false);
|
||||
local_renderer.end_frame();
|
||||
local_renderer.wait_idle(); // TODO get a semaphore from end_frame instead
|
||||
|
||||
write_image(device, queue, queue_family_index, local_screenshot_path, output);
|
||||
|
||||
return std::make_pair(local_path, env);
|
||||
},
|
||||
lobby_file_picker_future.get());
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
spdlog::warn("Cannot load local environment: {}", e.what());
|
||||
load_environment_status = fmt::format(_F("Cannot load local environment: {}"), e.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,16 @@ layout(set = 0, binding = 4) uniform sampler2D metallic_roughness_texture;
|
||||
layout(set = 0, binding = 5) uniform sampler2D occlusion_texture;
|
||||
layout(set = 0, binding = 6) uniform sampler2D emissive_texture;
|
||||
layout(set = 0, binding = 7) uniform sampler2D normal_map_texture;
|
||||
layout(set = 0, binding = 8) uniform material_ubo
|
||||
|
||||
struct texture_info
|
||||
{
|
||||
int texcoord;
|
||||
float rotation;
|
||||
vec2 offset;
|
||||
vec2 scale;
|
||||
};
|
||||
|
||||
layout(std140, set = 0, binding = 8) uniform material_ubo
|
||||
{
|
||||
vec4 base_color_factor;
|
||||
vec4 base_emissive_factor;
|
||||
@@ -43,11 +52,11 @@ layout(set = 0, binding = 8) uniform material_ubo
|
||||
float normal_scale;
|
||||
float alpha_cutoff;
|
||||
|
||||
int base_color_texcoord;
|
||||
int metallic_roughness_texcoord;
|
||||
int occlusion_texcoord;
|
||||
int emissive_texcoord;
|
||||
int normal_texcoord;
|
||||
texture_info base_color;
|
||||
texture_info metallic_roughness;
|
||||
texture_info occlusion;
|
||||
texture_info emissive;
|
||||
texture_info normal;
|
||||
} material;
|
||||
|
||||
const float dither_pattern[4][4] = {
|
||||
@@ -91,6 +100,26 @@ vec4 dither(ivec2 frag_coord, vec4 colour)
|
||||
return colour + one_over_d_linear_to_srgb(colour) * vec4(dither_thd, dither_thd, dither_thd, 0) / 255.0f;
|
||||
}
|
||||
|
||||
vec2 compute_texcoord(texture_info info, vec2 in_texcoord)
|
||||
{
|
||||
mat3 translation = mat3(
|
||||
1, 0, 0,
|
||||
0, 1, 0,
|
||||
info.offset.x, info.offset.y, 1);
|
||||
mat3 rotation = mat3(
|
||||
cos(info.rotation), sin(info.rotation), 0,
|
||||
-sin(info.rotation), cos(info.rotation), 0,
|
||||
0, 0, 1);
|
||||
mat3 scale = mat3(
|
||||
info.scale.x, 0, 0,
|
||||
0, info.scale.y, 0,
|
||||
0, 0, 1);
|
||||
|
||||
mat3 matrix = translation * rotation * scale;
|
||||
|
||||
return (matrix * vec3(in_texcoord, 1)).xy;
|
||||
}
|
||||
|
||||
#ifdef FRAG_SHADER
|
||||
#define VS_TO_FS in
|
||||
#else
|
||||
@@ -102,4 +131,8 @@ layout(location = 0) VS_TO_FS vec3 normal;
|
||||
layout(location = 1) VS_TO_FS vec4 tangent;
|
||||
layout(location = 2) VS_TO_FS vec4 frag_pos;
|
||||
layout(location = 3) VS_TO_FS vec4 light_pos;
|
||||
layout(location = 4) VS_TO_FS vec2 texcoord[nb_texcoords];
|
||||
layout(location = 4) VS_TO_FS vec2 texcoord_base_color;
|
||||
layout(location = 5) VS_TO_FS vec2 texcoord_metallic_roughness;
|
||||
layout(location = 6) VS_TO_FS vec2 texcoord_occlusion;
|
||||
layout(location = 7) VS_TO_FS vec2 texcoord_emissive;
|
||||
layout(location = 8) VS_TO_FS vec2 texcoord_normal;
|
||||
|
||||
@@ -30,14 +30,14 @@ layout(early_fragment_tests) in;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 albedo = material.base_color_factor * texture(base_color_texture, texcoord[0]);
|
||||
vec3 emissive_color = (material.base_emissive_factor * texture(emissive_texture, texcoord[0])).rgb;
|
||||
vec4 albedo = material.base_color_factor * texture(base_color_texture, texcoord_base_color);
|
||||
vec3 emissive_color = (material.base_emissive_factor * texture(emissive_texture, texcoord_emissive)).rgb;
|
||||
|
||||
vec3 normal_unit;
|
||||
|
||||
if (use_normal_maps)
|
||||
{
|
||||
vec3 sampled_normal = normalize(vec3(material.normal_scale, material.normal_scale, 1) * (texture(normal_map_texture, texcoord[0]).xyz * 2 - 1));
|
||||
vec3 sampled_normal = normalize(vec3(material.normal_scale, material.normal_scale, 1) * (texture(normal_map_texture, texcoord_normal).xyz * 2 - 1));
|
||||
|
||||
// glTF spec §3.7.2.1
|
||||
vec3 bitangent = cross(normal, tangent.xyz) * tangent.w;
|
||||
@@ -54,8 +54,8 @@ void main()
|
||||
|
||||
if (use_pbr)
|
||||
{
|
||||
float ao = 1 + material.occlusion_strength * (texture(occlusion_texture, texcoord[0]).r - 1);
|
||||
vec4 mr = texture(metallic_roughness_texture, texcoord[0]);
|
||||
float ao = 1 + material.occlusion_strength * (texture(occlusion_texture, texcoord_occlusion).r - 1);
|
||||
vec4 mr = texture(metallic_roughness_texture, texcoord_metallic_roughness);
|
||||
|
||||
vec3 half_vec = normalize(light_dir + view_dir);
|
||||
|
||||
|
||||
@@ -34,14 +34,16 @@ layout(location = 5) in vec4 in_color;
|
||||
out gl_PerVertex
|
||||
{
|
||||
vec4 gl_Position;
|
||||
float gl_ClipDistance[nb_clipping];
|
||||
float gl_ClipDistance[nb_clipping];
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
// TODO: use base_color_texcoord et al instead of always using texcoord 0
|
||||
for (int i = 0; i < nb_texcoords; i++)
|
||||
texcoord[i] = in_texcoord[i];
|
||||
texcoord_base_color = compute_texcoord(material.base_color, in_texcoord[material.base_color.texcoord]);
|
||||
texcoord_metallic_roughness = compute_texcoord(material.metallic_roughness, in_texcoord[material.metallic_roughness.texcoord]);
|
||||
texcoord_occlusion = compute_texcoord(material.occlusion, in_texcoord[material.occlusion.texcoord]);
|
||||
texcoord_emissive = compute_texcoord(material.emissive, in_texcoord[material.emissive.texcoord]);
|
||||
texcoord_normal = compute_texcoord(material.normal, in_texcoord[material.normal.texcoord]);
|
||||
|
||||
// TODO on CPU?
|
||||
mat3 mv = inverse(transpose(mat3(mesh.modelview[gl_ViewIndex])));
|
||||
@@ -57,8 +59,8 @@ void main()
|
||||
frag_pos = mesh.modelview[gl_ViewIndex] * vec4(in_position, 1.0);
|
||||
light_pos = scene.view[gl_ViewIndex] * scene.light_position;
|
||||
|
||||
for(int i = 0; i < nb_clipping; i++)
|
||||
for (int i = 0; i < nb_clipping; i++)
|
||||
{
|
||||
gl_ClipDistance[i] = dot(mesh.clipping_plane[i], mesh.model * vec4(in_position, 1.0));
|
||||
gl_ClipDistance[i] = dot(mesh.clipping_plane[i], mesh.model * vec4(in_position, 1.0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,14 +30,14 @@ layout(location = 0) out vec4 out_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 albedo = material.base_color_factor * texture(base_color_texture, texcoord[0]);
|
||||
vec3 emissive_color = (material.base_emissive_factor * texture(emissive_texture, texcoord[0])).rgb;
|
||||
vec4 albedo = material.base_color_factor * texture(base_color_texture, texcoord_base_color);
|
||||
vec3 emissive_color = (material.base_emissive_factor * texture(emissive_texture, texcoord_emissive)).rgb;
|
||||
|
||||
vec3 normal_unit;
|
||||
|
||||
if (use_normal_maps)
|
||||
{
|
||||
vec3 sampled_normal = normalize(vec3(material.normal_scale, material.normal_scale, 1) * (texture(normal_map_texture, texcoord[0]).xyz * 2 - 1));
|
||||
vec3 sampled_normal = normalize(vec3(material.normal_scale, material.normal_scale, 1) * (texture(normal_map_texture, texcoord_normal).xyz * 2 - 1));
|
||||
|
||||
// glTF spec §3.7.2.1
|
||||
vec3 bitangent = cross(normal, tangent.xyz) * tangent.w;
|
||||
@@ -54,8 +54,8 @@ void main()
|
||||
|
||||
if (use_pbr)
|
||||
{
|
||||
float ao = 1 + material.occlusion_strength * (texture(occlusion_texture, texcoord[0]).r - 1);
|
||||
vec4 mr = texture(metallic_roughness_texture, texcoord[0]);
|
||||
float ao = 1 + material.occlusion_strength * (texture(occlusion_texture, texcoord_occlusion).r - 1);
|
||||
vec4 mr = texture(metallic_roughness_texture, texcoord_metallic_roughness);
|
||||
|
||||
vec3 half_vec = normalize(light_dir + view_dir);
|
||||
|
||||
@@ -65,8 +65,8 @@ void main()
|
||||
vec3 light_colour = scene.light_color.rgb;
|
||||
float attenuation = 1;
|
||||
vec3 radiance =
|
||||
per_light_radiance(albedo.rgb, metallic, roughness, light_colour, light_dir, normal_unit, view_dir, half_vec, attenuation) +
|
||||
vec3(scene.ambient_color) * albedo.rgb * ao;
|
||||
per_light_radiance(albedo.rgb, metallic, roughness, light_colour, light_dir, normal_unit, view_dir, half_vec, attenuation) +
|
||||
vec3(scene.ambient_color) * albedo.rgb * ao;
|
||||
|
||||
vec3 tmp = radiance + emissive_color;
|
||||
|
||||
|
||||
@@ -36,14 +36,16 @@ layout(location = 7) in vec4 in_weights;
|
||||
out gl_PerVertex
|
||||
{
|
||||
vec4 gl_Position;
|
||||
float gl_ClipDistance[nb_clipping];
|
||||
float gl_ClipDistance[nb_clipping];
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
// TODO: use base_color_texcoord et al instead of always using texcoord 0
|
||||
for (int i = 0; i < nb_texcoords; i++)
|
||||
texcoord[i] = in_texcoord[i];
|
||||
texcoord_base_color = compute_texcoord(material.base_color, in_texcoord[material.base_color.texcoord]);
|
||||
texcoord_metallic_roughness = compute_texcoord(material.metallic_roughness, in_texcoord[material.metallic_roughness.texcoord]);
|
||||
texcoord_occlusion = compute_texcoord(material.occlusion, in_texcoord[material.occlusion.texcoord]);
|
||||
texcoord_emissive = compute_texcoord(material.emissive, in_texcoord[material.emissive.texcoord]);
|
||||
texcoord_normal = compute_texcoord(material.normal, in_texcoord[material.normal.texcoord]);
|
||||
|
||||
mat4 skinMatrix =
|
||||
in_weights.x * joints.joint_matrices[int(in_joints.x)] +
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Guillaume Meunier <guillaume.meunier@centraliens.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
|
||||
template <typename T>
|
||||
struct class_from_member
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename U>
|
||||
struct class_from_member<T U::*>
|
||||
{
|
||||
using type = U;
|
||||
};
|
||||
|
||||
template <typename pointer>
|
||||
using class_from_member_t = class_from_member<pointer>::type;
|
||||
@@ -93,11 +93,21 @@ public:
|
||||
return *resource;
|
||||
}
|
||||
|
||||
operator const T() const
|
||||
{
|
||||
return *resource;
|
||||
}
|
||||
|
||||
operator CType()
|
||||
{
|
||||
return CType(*resource);
|
||||
}
|
||||
|
||||
operator const CType() const
|
||||
{
|
||||
return CType(*resource);
|
||||
}
|
||||
|
||||
operator bool() const
|
||||
{
|
||||
return *resource;
|
||||
|
||||
@@ -16,6 +16,8 @@ msgstr ""
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Generator: Lokalize 25.08.3\n"
|
||||
"X-Language: es\n"
|
||||
"X-Source-Language: en\n"
|
||||
|
||||
#: dashboard/apk_installer.cpp:137
|
||||
#, kde-format
|
||||
@@ -103,13 +105,13 @@ msgstr ""
|
||||
#: dashboard/qml/ApkInstallPage.qml:51 dashboard/qml/WizardPage.qml:204
|
||||
#, kde-format
|
||||
msgid ""
|
||||
"Follow the instructions in the <a href=\"https://github.com/WiVRn/WiVRn/blob/"
|
||||
"master/docs/building.md#client-headset\">documentation</a> to build your own "
|
||||
"client."
|
||||
"Follow the instructions in the <a "
|
||||
"href=\"https://github.com/WiVRn/WiVRn/blob/master/docs/building.md#client-headset\">documentation</a> "
|
||||
"to build your own client."
|
||||
msgstr ""
|
||||
"Sigue las instrucciones en la <a href=\"https://github.com/WiVRn/WiVRn/blob/"
|
||||
"master/docs/building.md#client-headset\">documentación</a> para compilar tu "
|
||||
"propio cliente."
|
||||
"Sigue las instrucciones en la <a "
|
||||
"href=\"https://github.com/WiVRn/WiVRn/blob/master/docs/building.md#client-headset\">documentación</a> "
|
||||
"para compilar tu propio cliente."
|
||||
|
||||
#: dashboard/qml/ApkInstallPage.qml:65 dashboard/qml/HeadsetsPage.qml:183
|
||||
#: dashboard/qml/HeadsetStatsPage.qml:36 dashboard/qml/TroubleshootPage.qml:67
|
||||
@@ -292,14 +294,14 @@ msgstr ""
|
||||
#, kde-format
|
||||
msgid "Steam is installed as a snap. Snaps are not compatible with WiVRn."
|
||||
msgstr ""
|
||||
"Steam está instalado mediante snap. Los Snaps no son compatibles con WiVRn"
|
||||
"Steam está instalado mediante snap. Los Snaps no son compatibles con WiVRn."
|
||||
|
||||
#: dashboard/qml/Main.qml:183
|
||||
#, kde-format
|
||||
msgid ""
|
||||
"Steam is installed as a flatpak but does not have sufficient permissions."
|
||||
msgstr ""
|
||||
"Steam está instalado con flatpak, pero no tiene los suficientes permisos"
|
||||
"Steam está instalado con flatpak, pero no tiene los suficientes permisos."
|
||||
|
||||
#: dashboard/qml/Main.qml:198
|
||||
#, kde-format
|
||||
@@ -476,7 +478,7 @@ msgstr "Restablecer"
|
||||
#: dashboard/qml/SettingsPage.qml:116
|
||||
#, kde-format
|
||||
msgid "Encoder:"
|
||||
msgstr "Codificador"
|
||||
msgstr "Codificador:"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:122
|
||||
#, kde-format
|
||||
@@ -512,7 +514,7 @@ msgstr "\"Auto\" utilizará aceleración por hardware si está disponible"
|
||||
#: dashboard/qml/SettingsPage.qml:160
|
||||
#, kde-format
|
||||
msgid "Codec:"
|
||||
msgstr "Códec"
|
||||
msgstr "Códec:"
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:166
|
||||
#, kde-format
|
||||
@@ -573,7 +575,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"El teclado y ratón conectados al cliente actuarán como si se hubiesen "
|
||||
"conectado al servidor. El SO del cliente podria reservarse ciertas teclas y "
|
||||
"combinaciones, los cuales no podrán ser enviados"
|
||||
"combinaciones, los cuales no podrán ser enviados."
|
||||
|
||||
#: dashboard/qml/SettingsPage.qml:241
|
||||
#, kde-format
|
||||
@@ -719,9 +721,9 @@ msgstr "Tengo un error de \"Servidor WiVRn incompatible\" en mi visor"
|
||||
#: dashboard/qml/TroubleshootPage.qml:37
|
||||
#, kde-format
|
||||
msgid ""
|
||||
"<p>The version of the headset app and the server on your computer must match."
|
||||
"</p><ul><li>The headset app version is in the \"About\" page</li><li>The "
|
||||
"server version is <b>%1</b></li></ul>"
|
||||
"<p>The version of the headset app and the server on your computer must "
|
||||
"match.</p><ul><li>The headset app version is in the \"About\" "
|
||||
"page</li><li>The server version is <b>%1</b></li></ul>"
|
||||
msgstr ""
|
||||
"<p>La versión de la aplicación del visor y la del servidor en tu computadora "
|
||||
"deben coincidir.</p><ul><li>La versión de la aplicación del visor está en la "
|
||||
@@ -909,7 +911,7 @@ msgid ""
|
||||
"running."
|
||||
msgstr ""
|
||||
"WiVRn sustituye completamente a SteamVR, no deberías iniciar SteamVR "
|
||||
"mientras WiVRn esté en ejecución"
|
||||
"mientras WiVRn esté en ejecución."
|
||||
|
||||
#: dashboard/qml/WizardPage.qml:359
|
||||
#, kde-format
|
||||
|
||||
+40
-24
@@ -5,7 +5,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WiVRn 0.15\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2025-11-17 21:03+0100\n"
|
||||
"POT-Creation-Date: 2025-12-02 19:57+0100\n"
|
||||
"PO-Revision-Date: 2025-11-19 20:23+0100\n"
|
||||
"Last-Translator: Álvaro De Quinta <blackcherry@danwin1210.de>\n"
|
||||
"Language-Team: Spanish <>\n"
|
||||
@@ -15,6 +15,8 @@ msgstr ""
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Generator: Lokalize 25.08.3\n"
|
||||
"X-Language: es\n"
|
||||
"X-Source-Language: en\n"
|
||||
|
||||
#: client/scene.cpp:73
|
||||
msgid "No supported swapchain format"
|
||||
@@ -31,19 +33,19 @@ msgstr "Connectado a {}"
|
||||
|
||||
#: client/scenes/app_launcher.cpp:136
|
||||
msgid "Start an application on the server to start streaming."
|
||||
msgstr "Inicia una aplicación en el servidor para empezar la retransmisión"
|
||||
msgstr "Inicia una aplicación en el servidor para empezar la retransmisión."
|
||||
|
||||
#: client/scenes/app_launcher.cpp:146
|
||||
msgid "Start an application on your computer or select one to start streaming."
|
||||
msgstr ""
|
||||
"Inicia una aplicación en tu ordenador o selecciona una para empezar la "
|
||||
"retransmisión"
|
||||
"retransmisión."
|
||||
|
||||
#: client/scenes/app_launcher.cpp:148
|
||||
#, c++-format
|
||||
msgid "Start an application on {} or select one to start streaming."
|
||||
msgstr ""
|
||||
"Inicia una aplicación en {} o selecciona una para empezar la retransmisión"
|
||||
"Inicia una aplicación en {} o selecciona una para empezar la retransmisión."
|
||||
|
||||
#: client/scenes/lobby.cpp:230
|
||||
msgid "Incompatible WiVRn server: no protocol field in TXT"
|
||||
@@ -96,9 +98,9 @@ msgstr "Deshabilitado"
|
||||
msgid "Disconnect"
|
||||
msgstr "Desconectar"
|
||||
|
||||
#: client/scenes/lobby_gui.cpp:132 client/scenes/lobby_gui_customize.cpp:653
|
||||
#: client/scenes/lobby_gui_customize.cpp:744
|
||||
#: client/scenes/lobby_gui_customize.cpp:800 client/scenes/stream_gui.cpp:963
|
||||
#: client/scenes/lobby_gui.cpp:132 client/scenes/lobby_gui_customize.cpp:749
|
||||
#: client/scenes/lobby_gui_customize.cpp:840
|
||||
#: client/scenes/lobby_gui_customize.cpp:896 client/scenes/stream_gui.cpp:963
|
||||
msgid "Close"
|
||||
msgstr "Cerrar"
|
||||
|
||||
@@ -135,7 +137,7 @@ msgstr "Puerto"
|
||||
msgid "TCP only"
|
||||
msgstr "Solo TCP"
|
||||
|
||||
#: client/scenes/lobby_gui.cpp:317 client/scenes/lobby_gui_customize.cpp:555
|
||||
#: client/scenes/lobby_gui.cpp:317 client/scenes/lobby_gui_customize.cpp:651
|
||||
#: client/scenes/stream_gui.cpp:920
|
||||
msgid "Cancel"
|
||||
msgstr "Cancelar"
|
||||
@@ -252,7 +254,7 @@ msgstr "Activar seguimiento de manos"
|
||||
|
||||
#: client/scenes/lobby_gui.cpp:709 client/scenes/lobby_gui.cpp:721
|
||||
#: client/scenes/lobby_gui.cpp:733 client/scenes/lobby_gui.cpp:750
|
||||
#: client/scenes/lobby_gui_customize.cpp:540
|
||||
#: client/scenes/lobby_gui_customize.cpp:636
|
||||
msgid "This feature is not supported by your headset"
|
||||
msgstr "Esta función no es compatible con tu visor"
|
||||
|
||||
@@ -482,33 +484,47 @@ msgstr ""
|
||||
msgid "Press the grip button to move the main window"
|
||||
msgstr "Pulsa el botón de agarre para mover la ventana principal"
|
||||
|
||||
#: client/scenes/lobby_gui_customize.cpp:233
|
||||
#: client/scenes/lobby_gui_customize.cpp:208
|
||||
msgid "Locally loaded environment"
|
||||
msgstr "Entorno local cargado"
|
||||
|
||||
#: client/scenes/lobby_gui_customize.cpp:221
|
||||
#, c++-format
|
||||
msgid "Locally loaded environment ({})"
|
||||
msgstr "Entorno local ({}) cargado"
|
||||
|
||||
#: client/scenes/lobby_gui_customize.cpp:296
|
||||
#, c++-format
|
||||
msgid "Cannot load local environment: {}"
|
||||
msgstr "No se ha podido cargar el entorno local: {}"
|
||||
|
||||
#: client/scenes/lobby_gui_customize.cpp:329
|
||||
#, c++-format
|
||||
msgid "Cannot load environment list: {}"
|
||||
msgstr "No se ha podido cargar la lista del entorno: {}"
|
||||
|
||||
#: client/scenes/lobby_gui_customize.cpp:363
|
||||
#: client/scenes/lobby_gui_customize.cpp:459
|
||||
#, c++-format
|
||||
msgid "Author: {}"
|
||||
msgstr "Autor: {}"
|
||||
|
||||
#: client/scenes/lobby_gui_customize.cpp:367
|
||||
#: client/scenes/lobby_gui_customize.cpp:463
|
||||
#, c++-format
|
||||
msgid "Size: {:.1f} MB"
|
||||
msgstr "Tamaño: {:.1f} MB"
|
||||
|
||||
#: client/scenes/lobby_gui_customize.cpp:447
|
||||
#: client/scenes/lobby_gui_customize.cpp:543
|
||||
msgid "Delete this model"
|
||||
msgstr "Borrar este modelo"
|
||||
|
||||
#: client/scenes/lobby_gui_customize.cpp:483
|
||||
#: client/scenes/lobby_gui_customize.cpp:689
|
||||
#: client/scenes/lobby_gui_customize.cpp:579
|
||||
#: client/scenes/lobby_gui_customize.cpp:785
|
||||
#, c++-format
|
||||
msgid "HTTP error {} when downloading {}"
|
||||
msgstr "Error HTTP {} mientras se descargaba {}"
|
||||
|
||||
#: client/scenes/lobby_gui_customize.cpp:491
|
||||
#: client/scenes/lobby_gui_customize.cpp:697
|
||||
#: client/scenes/lobby_gui_customize.cpp:587
|
||||
#: client/scenes/lobby_gui_customize.cpp:793
|
||||
#, c++-format
|
||||
msgid ""
|
||||
"Curl error when downloading {}\n"
|
||||
@@ -517,29 +533,29 @@ msgstr ""
|
||||
"Error de Curl mientras se descargaba {}\n"
|
||||
"{}: {}"
|
||||
|
||||
#: client/scenes/lobby_gui_customize.cpp:552
|
||||
#: client/scenes/lobby_gui_customize.cpp:648
|
||||
#, c++-format
|
||||
msgid "Really delete {}?"
|
||||
msgstr "Seguro que quiere borrar {}?"
|
||||
|
||||
#: client/scenes/lobby_gui_customize.cpp:556
|
||||
#: client/scenes/lobby_gui_customize.cpp:652
|
||||
msgid "Delete"
|
||||
msgstr "Borrar"
|
||||
|
||||
#: client/scenes/lobby_gui_customize.cpp:637
|
||||
#: client/scenes/lobby_gui_customize.cpp:733
|
||||
#, c++-format
|
||||
msgid "Cannot load environment: {}"
|
||||
msgstr "No se puede cargar el entorno: {}"
|
||||
|
||||
#: client/scenes/lobby_gui_customize.cpp:645
|
||||
#: client/scenes/lobby_gui_customize.cpp:741
|
||||
msgid "Loading environment"
|
||||
msgstr "Cargando entorno"
|
||||
|
||||
#: client/scenes/lobby_gui_customize.cpp:724
|
||||
#: client/scenes/lobby_gui_customize.cpp:820
|
||||
msgid "Download more environments"
|
||||
msgstr "Descargar más entornos"
|
||||
|
||||
#: client/scenes/lobby_gui_customize.cpp:732
|
||||
#: client/scenes/lobby_gui_customize.cpp:828
|
||||
msgid "Open local glTF model"
|
||||
msgstr "Abrir modelo glTF local"
|
||||
|
||||
@@ -697,7 +713,7 @@ msgstr "No se puede verificar el PIN"
|
||||
|
||||
#: client/wivrn_client.cpp:182
|
||||
msgid "Pairing is disabled on server"
|
||||
msgstr "El emparejamiento está deshabilitado en el servidor."
|
||||
msgstr "El emparejamiento está deshabilitado en el servidor"
|
||||
|
||||
#, c++-format
|
||||
#~ msgid "HTTP error {} when downloading index.json"
|
||||
|
||||
@@ -166,7 +166,7 @@ wivrn::video_encoder_vulkan_h265::video_encoder_vulkan_h265(
|
||||
.cu_qp_delta_enabled_flag = 1, // must be 1 or nvidia breaks
|
||||
.transquant_bypass_enabled_flag = 0, // only 1 when tuned for lossless
|
||||
.deblocking_filter_control_present_flag = 1,
|
||||
.pps_range_extension_flag = (settings.bit_depth == 10) ? 1u : 0u,
|
||||
.pps_range_extension_flag = 0u,
|
||||
},
|
||||
|
||||
.pps_pic_parameter_set_id = 0,
|
||||
|
||||
Reference in New Issue
Block a user