Fixed vaapi filter not working with newer ffmpeg
Added pico neo 3 and pico 4 profiles with switching Removed gles requirements
This commit is contained in:
@@ -3,8 +3,6 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="org.meumeu.wivrn"
|
package="org.meumeu.wivrn"
|
||||||
android:installLocation="auto">
|
android:installLocation="auto">
|
||||||
<!-- Tell the system this app requires OpenGL ES 3.2. -->
|
|
||||||
<uses-feature android:glEsVersion="0x00030002" android:required="true"/>
|
|
||||||
|
|
||||||
<!-- Tell the system this app works in either 3dof or 6dof mode -->
|
<!-- Tell the system this app works in either 3dof or 6dof mode -->
|
||||||
<uses-feature android:name="android.hardware.vr.headtracking" android:required="true" android:version="1" />
|
<uses-feature android:name="android.hardware.vr.headtracking" android:required="true" android:version="1" />
|
||||||
|
|||||||
+49
-17
@@ -36,6 +36,7 @@
|
|||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <vulkan/vulkan_core.h>
|
#include <vulkan/vulkan_core.h>
|
||||||
#include <openxr/openxr_platform.h>
|
#include <openxr/openxr_platform.h>
|
||||||
|
#include <sys/system_properties.h>
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#include "utils/backtrace.h"
|
#include "utils/backtrace.h"
|
||||||
@@ -408,36 +409,67 @@ void application::initialize()
|
|||||||
|
|
||||||
// TODO get it from application info
|
// TODO get it from application info
|
||||||
xr_actionset = xr::actionset(xr_instance, "actions", "Actions");
|
xr_actionset = xr::actionset(xr_instance, "actions", "Actions");
|
||||||
std::vector<XrActionSuggestedBinding> bindings;
|
|
||||||
|
|
||||||
for (const auto & [name, type]: oculus_touch)
|
// TODO better way to handle bindings for different vendors/flavors of vendor
|
||||||
{
|
char model_chararr[PROP_VALUE_MAX+1];
|
||||||
std::string name_without_slashes = std::string(name).substr(1);
|
__system_property_get("ro.product.model", model_chararr);
|
||||||
|
std::string model_string(model_chararr);
|
||||||
|
|
||||||
for (char & i: name_without_slashes)
|
if (model_string == "Oculus Quest 2") {
|
||||||
|
spdlog::info("Suggesting Oculus Quest 2 bindings");
|
||||||
|
std::vector<XrActionSuggestedBinding> touch_controller_bindings;
|
||||||
|
for (const auto & [name, type]: oculus_touch)
|
||||||
{
|
{
|
||||||
if (i == '/')
|
process_binding_action(touch_controller_bindings, name, type);
|
||||||
i = '_';
|
|
||||||
}
|
}
|
||||||
|
xr_instance.suggest_bindings("/interaction_profiles/oculus/touch_controller", touch_controller_bindings);
|
||||||
auto a = xr_actionset.create_action(type, name_without_slashes);
|
} else if (model_string == "Pico Neo 3") {
|
||||||
actions.emplace_back(a, type, name);
|
spdlog::info("Suggesting Pico Neo 3 bindings");
|
||||||
|
std::vector<XrActionSuggestedBinding> pico_neo_3_bindings;
|
||||||
if (type == XR_ACTION_TYPE_POSE_INPUT)
|
for (const auto & [name, type]: pico_neo_3)
|
||||||
{
|
{
|
||||||
action_spaces.push_back(xr_session.create_action_space(a));
|
process_binding_action(pico_neo_3_bindings, name, type);
|
||||||
}
|
}
|
||||||
|
xr_instance.suggest_bindings("/interaction_profiles/bytedance/pico_neo3_controller", pico_neo_3_bindings);
|
||||||
bindings.push_back({a, xr_instance.string_to_path(name)});
|
} else if (model_string == "Pico 4") {
|
||||||
|
spdlog::info("Suggesting Pico 4 bindings");
|
||||||
|
std::vector<XrActionSuggestedBinding> pico_4_bindings;
|
||||||
|
for (const auto & [name, type]: pico_4)
|
||||||
|
{
|
||||||
|
process_binding_action(pico_4_bindings, name, type);
|
||||||
|
}
|
||||||
|
xr_instance.suggest_bindings("/interaction_profiles/bytedance/pico4_controller", pico_4_bindings);
|
||||||
|
} else {
|
||||||
|
spdlog::error("Couldn't find any compatible suggested bindings");
|
||||||
}
|
}
|
||||||
|
|
||||||
xr_instance.suggest_bindings("/interaction_profiles/oculus/touch_controller", bindings);
|
|
||||||
|
|
||||||
xr_session.attach_actionsets({xr_actionset});
|
xr_session.attach_actionsets({xr_actionset});
|
||||||
|
|
||||||
interaction_profile_changed();
|
interaction_profile_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void application::process_binding_action(std::vector<XrActionSuggestedBinding> & bindings,
|
||||||
|
const char *name,
|
||||||
|
const XrActionType &type) {
|
||||||
|
std::string name_without_slashes = std::string(name).substr(1);
|
||||||
|
|
||||||
|
for (char & i: name_without_slashes)
|
||||||
|
{
|
||||||
|
if (i == '/')
|
||||||
|
i = '_';
|
||||||
|
}
|
||||||
|
|
||||||
|
auto a = xr_actionset.create_action(type, name_without_slashes);
|
||||||
|
actions.emplace_back(a, type, name);
|
||||||
|
|
||||||
|
if (type == XR_ACTION_TYPE_POSE_INPUT)
|
||||||
|
{
|
||||||
|
action_spaces.push_back(xr_session.create_action_space(a));
|
||||||
|
}
|
||||||
|
|
||||||
|
bindings.push_back({a, xr_instance.string_to_path(name)});
|
||||||
|
}
|
||||||
|
|
||||||
std::pair<XrAction, XrActionType> application::get_action(const std::string & requested_name)
|
std::pair<XrAction, XrActionType> application::get_action(const std::string & requested_name)
|
||||||
{
|
{
|
||||||
for (const auto & [action, type, name]: instance_->actions)
|
for (const auto & [action, type, name]: instance_->actions)
|
||||||
|
|||||||
@@ -171,6 +171,83 @@ class application
|
|||||||
{"/user/hand/right/input/thumbstick/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
{"/user/hand/right/input/thumbstick/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
{"/user/hand/right/input/thumbstick/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
{"/user/hand/right/input/thumbstick/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
{"/user/hand/right/input/thumbrest/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
{"/user/hand/right/input/thumbrest/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
};
|
||||||
|
static inline const std::pair<const char *, XrActionType> pico_neo_3[] = {
|
||||||
|
{"/user/hand/left/output/haptic", XR_ACTION_TYPE_VIBRATION_OUTPUT},
|
||||||
|
{"/user/hand/right/output/haptic", XR_ACTION_TYPE_VIBRATION_OUTPUT},
|
||||||
|
|
||||||
|
{"/user/hand/left/input/grip/pose", XR_ACTION_TYPE_POSE_INPUT},
|
||||||
|
{"/user/hand/left/input/aim/pose", XR_ACTION_TYPE_POSE_INPUT},
|
||||||
|
|
||||||
|
{"/user/hand/right/input/grip/pose", XR_ACTION_TYPE_POSE_INPUT},
|
||||||
|
{"/user/hand/right/input/aim/pose", XR_ACTION_TYPE_POSE_INPUT},
|
||||||
|
|
||||||
|
{"/user/hand/left/input/x/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/left/input/x/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/left/input/y/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/left/input/y/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/left/input/squeeze/value", XR_ACTION_TYPE_FLOAT_INPUT},
|
||||||
|
{"/user/hand/left/input/trigger/value", XR_ACTION_TYPE_FLOAT_INPUT},
|
||||||
|
{"/user/hand/left/input/trigger/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/left/input/thumbstick", XR_ACTION_TYPE_VECTOR2F_INPUT},
|
||||||
|
{"/user/hand/left/input/thumbstick/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/left/input/thumbstick/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/left/input/thumbrest/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
|
||||||
|
{"/user/hand/right/input/a/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/right/input/a/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/right/input/b/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/right/input/b/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/right/input/squeeze/value", XR_ACTION_TYPE_FLOAT_INPUT},
|
||||||
|
{"/user/hand/right/input/trigger/value", XR_ACTION_TYPE_FLOAT_INPUT},
|
||||||
|
{"/user/hand/right/input/trigger/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/right/input/thumbstick", XR_ACTION_TYPE_VECTOR2F_INPUT},
|
||||||
|
{"/user/hand/right/input/thumbstick/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/right/input/thumbstick/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/right/input/thumbrest/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
|
||||||
|
{"/user/hand/left/input/menu/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/left/input/system/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/right/input/menu/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/right/input/system/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
};
|
||||||
|
static inline const std::pair<const char *, XrActionType> pico_4[] = {
|
||||||
|
{"/user/hand/left/output/haptic", XR_ACTION_TYPE_VIBRATION_OUTPUT},
|
||||||
|
{"/user/hand/right/output/haptic", XR_ACTION_TYPE_VIBRATION_OUTPUT},
|
||||||
|
|
||||||
|
{"/user/hand/left/input/grip/pose", XR_ACTION_TYPE_POSE_INPUT},
|
||||||
|
{"/user/hand/left/input/aim/pose", XR_ACTION_TYPE_POSE_INPUT},
|
||||||
|
|
||||||
|
{"/user/hand/right/input/grip/pose", XR_ACTION_TYPE_POSE_INPUT},
|
||||||
|
{"/user/hand/right/input/aim/pose", XR_ACTION_TYPE_POSE_INPUT},
|
||||||
|
|
||||||
|
{"/user/hand/left/input/x/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/left/input/x/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/left/input/y/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/left/input/y/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/left/input/squeeze/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/left/input/squeeze/value", XR_ACTION_TYPE_FLOAT_INPUT},
|
||||||
|
{"/user/hand/left/input/trigger/value", XR_ACTION_TYPE_FLOAT_INPUT},
|
||||||
|
{"/user/hand/left/input/trigger/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/left/input/thumbstick", XR_ACTION_TYPE_VECTOR2F_INPUT},
|
||||||
|
{"/user/hand/left/input/thumbstick/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/left/input/thumbstick/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/left/input/thumbrest/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
|
||||||
|
{"/user/hand/right/input/a/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/right/input/a/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/right/input/b/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/right/input/b/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/right/input/squeeze/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/right/input/squeeze/value", XR_ACTION_TYPE_FLOAT_INPUT},
|
||||||
|
{"/user/hand/right/input/trigger/value", XR_ACTION_TYPE_FLOAT_INPUT},
|
||||||
|
{"/user/hand/right/input/trigger/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/right/input/thumbstick", XR_ACTION_TYPE_VECTOR2F_INPUT},
|
||||||
|
{"/user/hand/right/input/thumbstick/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/right/input/thumbstick/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
{"/user/hand/right/input/thumbrest/touch", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
|
|
||||||
|
{"/user/hand/left/input/menu/click", XR_ACTION_TYPE_BOOLEAN_INPUT},
|
||||||
};
|
};
|
||||||
|
|
||||||
bool session_running = false;
|
bool session_running = false;
|
||||||
@@ -247,6 +324,10 @@ public:
|
|||||||
|
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
|
void process_binding_action(std::vector<XrActionSuggestedBinding> & bindings,
|
||||||
|
const char * name,
|
||||||
|
const XrActionType & type);
|
||||||
|
|
||||||
static void push_scene(std::shared_ptr<scene>);
|
static void push_scene(std::shared_ptr<scene>);
|
||||||
|
|
||||||
template <typename T, typename... Args>
|
template <typename T, typename... Args>
|
||||||
|
|||||||
@@ -303,19 +303,22 @@ void VideoEncoderVA::InitFilterGraph()
|
|||||||
AVFilterInOut * outputs = avfilter_inout_alloc();
|
AVFilterInOut * outputs = avfilter_inout_alloc();
|
||||||
AVFilterInOut * inputs = avfilter_inout_alloc();
|
AVFilterInOut * inputs = avfilter_inout_alloc();
|
||||||
|
|
||||||
filter_in = avfilter_graph_alloc_filter(filter_graph.get(), avfilter_get_by_name("buffer"), "in");
|
std::stringstream buffer_filter_args;
|
||||||
|
buffer_filter_args << "video_size=" << mapped_frames[0]->width << "x" << mapped_frames[0]->height;
|
||||||
|
buffer_filter_args << ":pix_fmt=" << mapped_frames[0]->format;
|
||||||
|
buffer_filter_args << ":time_base=" << encoder_ctx->time_base.num << "/" << encoder_ctx->time_base.den;
|
||||||
|
int err;
|
||||||
|
if ((err = avfilter_graph_create_filter(&filter_in, avfilter_get_by_name("buffer"), "in", buffer_filter_args.str().c_str(), NULL, filter_graph.get())))
|
||||||
|
{
|
||||||
|
throw std::system_error(err, av_error_category(), "filter_in creation failed");
|
||||||
|
}
|
||||||
|
AVBufferSrcParameters *par = av_buffersrc_parameters_alloc();
|
||||||
|
memset(par, 0, sizeof(*par));
|
||||||
|
par->format = AV_PIX_FMT_NONE;
|
||||||
|
par->hw_frames_ctx = av_buffer_ref(mapped_frames[0]->hw_frames_ctx);
|
||||||
|
av_buffersrc_parameters_set(filter_in, par);
|
||||||
|
av_free(par);
|
||||||
|
|
||||||
AVBufferSrcParameters * par = av_buffersrc_parameters_alloc();
|
|
||||||
memset(par, 0, sizeof(*par));
|
|
||||||
par->width = mapped_frames[0]->width;
|
|
||||||
par->height = mapped_frames[0]->height;
|
|
||||||
par->time_base = encoder_ctx->time_base;
|
|
||||||
par->format = mapped_frames[0]->format;
|
|
||||||
par->hw_frames_ctx = av_buffer_ref(mapped_frames[0]->hw_frames_ctx);
|
|
||||||
av_buffersrc_parameters_set(filter_in, par);
|
|
||||||
av_free(par);
|
|
||||||
|
|
||||||
int err;
|
|
||||||
if ((err = avfilter_graph_create_filter(&filter_out, avfilter_get_by_name("buffersink"), "out", NULL, NULL, filter_graph.get())))
|
if ((err = avfilter_graph_create_filter(&filter_out, avfilter_get_by_name("buffersink"), "out", NULL, NULL, filter_graph.get())))
|
||||||
{
|
{
|
||||||
throw std::system_error(err, av_error_category(), "filter_out creation failed");
|
throw std::system_error(err, av_error_category(), "filter_out creation failed");
|
||||||
@@ -338,7 +341,7 @@ void VideoEncoderVA::InitFilterGraph()
|
|||||||
avfilter_inout_free(&inputs);
|
avfilter_inout_free(&inputs);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
throw std::system_error(err, av_error_category(), "avfilter_graph_parse_ptr failed");
|
throw std::system_error(err, av_error_category(), "code "+ std::to_string(err) + "avfilter_graph_parse_ptr failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((err = avfilter_graph_config(filter_graph.get(), NULL)))
|
if ((err = avfilter_graph_config(filter_graph.get(), NULL)))
|
||||||
|
|||||||
Reference in New Issue
Block a user