st/oxr: Rename all num_ in the state tracker, too.

This commit is contained in:
Ryan Pavlik 2021-11-08 15:29:21 -06:00 committed by Jakob Bornecrantz
parent 33c0287f8b
commit 469b9d907d
22 changed files with 243 additions and 243 deletions

View file

@ -162,14 +162,14 @@ def generate_bindings_c(file, p):
fname = vendor_name + "_" + hw_name + "_profile.json"
controller_type = "monado_" + vendor_name + "_" + hw_name
num_bindings = len(profile.features)
binding_count = len(profile.features)
f.write(f'\t{{ // profile_template\n')
f.write(f'\t\t.name = {profile.monado_device},\n')
f.write(f'\t\t.path = "{profile.name}",\n')
f.write(f'\t\t.localized_name = "{profile.title}",\n')
f.write(f'\t\t.steamvr_input_profile_path = "{fname}",\n')
f.write(f'\t\t.steamvr_controller_type = "{controller_type}",\n')
f.write(f'\t\t.num_bindings = {num_bindings},\n')
f.write(f'\t\t.binding_count = {binding_count},\n')
f.write(
f'\t\t.bindings = (struct binding_template[]){{ // array of binding_template\n')
@ -301,7 +301,7 @@ struct profile_template
\tconst char *steamvr_input_profile_path;
\tconst char *steamvr_controller_type;
\tstruct binding_template *bindings;
\tsize_t num_bindings;
\tsize_t binding_count;
}};
#define NUM_PROFILE_TEMPLATES {len(p.profiles)}

View file

@ -321,14 +321,14 @@ try_move_assignment(struct xrt_device **xdevs, int *hand, int *other_hand)
}
void
u_device_assign_xdev_roles(struct xrt_device **xdevs, size_t num_xdevs, int *head, int *left, int *right)
u_device_assign_xdev_roles(struct xrt_device **xdevs, size_t xdev_count, int *head, int *left, int *right)
{
*head = XRT_DEVICE_ROLE_UNASSIGNED;
*left = XRT_DEVICE_ROLE_UNASSIGNED;
*right = XRT_DEVICE_ROLE_UNASSIGNED;
assert(num_xdevs < INT_MAX);
assert(xdev_count < INT_MAX);
for (size_t i = 0; i < num_xdevs; i++) {
for (size_t i = 0; i < xdev_count; i++) {
if (xdevs[i] == NULL) {
continue;
}
@ -365,7 +365,7 @@ u_device_assign_xdev_roles(struct xrt_device **xdevs, size_t num_xdevs, int *hea
}
// fill unassigned left/right with hand trackers if available
for (size_t i = 0; i < num_xdevs; i++) {
for (size_t i = 0; i < xdev_count; i++) {
if (xdevs[i] == NULL) {
continue;
}

View file

@ -129,7 +129,7 @@ u_device_free(struct xrt_device *xdev);
* @ingroup aux_util
*/
void
u_device_assign_xdev_roles(struct xrt_device **xdevs, size_t num_xdevs, int *head, int *left, int *right);
u_device_assign_xdev_roles(struct xrt_device **xdevs, size_t xdev_count, int *head, int *left, int *right);
/*!
* Helper function for setting up tracking origins. Applies 3dof offsets for devices with XRT_TRACKING_TYPE_NONE.

View file

@ -37,7 +37,7 @@ qwerty_create_auto_prober(void);
* gets created.
*/
void
qwerty_process_event(struct xrt_device **xdevs, size_t num_xdevs, SDL_Event event);
qwerty_process_event(struct xrt_device **xdevs, size_t xdev_count, SDL_Event event);
/*!
* @}

View file

@ -17,10 +17,10 @@
#define SENSITIVITY 0.1f
static struct qwerty_system *
find_qwerty_system(struct xrt_device **xdevs, size_t num_xdevs)
find_qwerty_system(struct xrt_device **xdevs, size_t xdev_count)
{
struct xrt_device *xdev = NULL;
for (size_t i = 0; i < num_xdevs; i++) {
for (size_t i = 0; i < xdev_count; i++) {
if (xdevs[i] == NULL) {
continue;
}
@ -44,11 +44,11 @@ find_qwerty_system(struct xrt_device **xdevs, size_t num_xdevs)
// Determines the default qwerty device based on which devices are in use
static struct qwerty_device *
default_qwerty_device(struct xrt_device **xdevs, size_t num_xdevs, struct qwerty_system *qsys)
default_qwerty_device(struct xrt_device **xdevs, size_t xdev_count, struct qwerty_system *qsys)
{
int head, left, right;
head = left = right = XRT_DEVICE_ROLE_UNASSIGNED;
u_device_assign_xdev_roles(xdevs, num_xdevs, &head, &left, &right);
u_device_assign_xdev_roles(xdevs, xdev_count, &head, &left, &right);
struct xrt_device *xd_hmd = qsys->hmd ? &qsys->hmd->base.base : NULL;
struct xrt_device *xd_left = &qsys->lctrl->base.base;
@ -70,11 +70,11 @@ default_qwerty_device(struct xrt_device **xdevs, size_t num_xdevs, struct qwerty
// Determines the default qwerty controller based on which devices are in use
static struct qwerty_controller *
default_qwerty_controller(struct xrt_device **xdevs, size_t num_xdevs, struct qwerty_system *qsys)
default_qwerty_controller(struct xrt_device **xdevs, size_t xdev_count, struct qwerty_system *qsys)
{
int head, left, right;
head = left = right = XRT_DEVICE_ROLE_UNASSIGNED;
u_device_assign_xdev_roles(xdevs, num_xdevs, &head, &left, &right);
u_device_assign_xdev_roles(xdevs, xdev_count, &head, &left, &right);
struct xrt_device *xd_left = &qsys->lctrl->base.base;
struct xrt_device *xd_right = &qsys->rctrl->base.base;
@ -92,7 +92,7 @@ default_qwerty_controller(struct xrt_device **xdevs, size_t num_xdevs, struct qw
}
void
qwerty_process_event(struct xrt_device **xdevs, size_t num_xdevs, SDL_Event event)
qwerty_process_event(struct xrt_device **xdevs, size_t xdev_count, SDL_Event event)
{
static struct qwerty_system *qsys = NULL;
@ -107,9 +107,9 @@ qwerty_process_event(struct xrt_device **xdevs, size_t num_xdevs, SDL_Event even
// We can cache the devices as they don't get destroyed during runtime
static bool cached = false;
if (!cached) {
qsys = find_qwerty_system(xdevs, num_xdevs);
default_qdev = default_qwerty_device(xdevs, num_xdevs, qsys);
default_qctrl = default_qwerty_controller(xdevs, num_xdevs, qsys);
qsys = find_qwerty_system(xdevs, xdev_count);
default_qdev = default_qwerty_device(xdevs, xdev_count, qsys);
default_qctrl = default_qwerty_controller(xdevs, xdev_count, qsys);
cached = true;
}

View file

@ -311,7 +311,7 @@ oxr_hand_tracker_create(struct oxr_logger *log,
//! @todo: move hand tracking device selection to oxr_system.
// if no xdev with hand tracking is found, create hand tracker without xdev.
for (uint32_t i = 0; i < sess->sys->num_xdevs; i++) {
for (uint32_t i = 0; i < sess->sys->xdev_count; i++) {
struct xrt_device *xdev = sess->sys->xdevs[i];
if (!xdev || !xdev->hand_tracking_supported) {

View file

@ -53,9 +53,9 @@ oxr_xrGetSystem(XrInstance instance, const XrSystemGetInfo *getInfo, XrSystemId
struct oxr_system *selected = NULL;
struct oxr_system *systems[1] = {&inst->system};
uint32_t num_systems = 1;
uint32_t system_count = ARRAY_SIZE(systems);
XrResult ret = oxr_system_select(&log, systems, num_systems, getInfo->formFactor, &selected);
XrResult ret = oxr_system_select(&log, systems, system_count, getInfo->formFactor, &selected);
if (ret != XR_SUCCESS) {
return ret;
}

View file

@ -31,10 +31,10 @@ setup_paths(struct oxr_logger *log,
count++;
}
binding->num_paths = count;
binding->path_count = count;
binding->paths = U_TYPED_ARRAY_CALLOC(XrPath, count);
for (size_t x = 0; x < binding->num_paths; x++) {
for (size_t x = 0; x < binding->path_count; x++) {
const char *str = templ->paths[x];
size_t len = strlen(str);
oxr_path_get_or_create(log, inst, str, len, &binding->paths[x]);
@ -47,7 +47,7 @@ interaction_profile_find(struct oxr_logger *log,
XrPath path,
struct oxr_interaction_profile **out_p)
{
for (size_t x = 0; x < inst->num_profiles; x++) {
for (size_t x = 0; x < inst->profile_count; x++) {
struct oxr_interaction_profile *p = inst->profiles[x];
if (p->path != path) {
continue;
@ -97,12 +97,12 @@ interaction_profile_find_or_create(struct oxr_logger *log,
struct oxr_interaction_profile *p = U_TYPED_CALLOC(struct oxr_interaction_profile);
p->xname = templ->name;
p->num_bindings = templ->num_bindings;
p->bindings = U_TYPED_ARRAY_CALLOC(struct oxr_binding, p->num_bindings);
p->binding_count = templ->binding_count;
p->bindings = U_TYPED_ARRAY_CALLOC(struct oxr_binding, p->binding_count);
p->path = path;
p->localized_name = templ->localized_name;
for (size_t x = 0; x < templ->num_bindings; x++) {
for (size_t x = 0; x < templ->binding_count; x++) {
struct binding_template *t = &templ->bindings[x];
struct oxr_binding *b = &p->bindings[x];
@ -124,8 +124,8 @@ interaction_profile_find_or_create(struct oxr_logger *log,
}
// Add to the list of currently created interaction profiles.
U_ARRAY_REALLOC_OR_FREE(inst->profiles, struct oxr_interaction_profile *, (inst->num_profiles + 1));
inst->profiles[inst->num_profiles++] = p;
U_ARRAY_REALLOC_OR_FREE(inst->profiles, struct oxr_interaction_profile *, (inst->profile_count + 1));
inst->profiles[inst->profile_count++] = p;
*out_p = p;
@ -139,26 +139,26 @@ reset_binding_keys(struct oxr_binding *binding)
free(binding->preferred_binding_path_index);
binding->keys = NULL;
binding->preferred_binding_path_index = NULL;
binding->num_keys = 0;
binding->key_count = 0;
}
static void
reset_all_keys(struct oxr_binding *bindings, size_t num_bindings)
reset_all_keys(struct oxr_binding *bindings, size_t binding_count)
{
for (size_t x = 0; x < num_bindings; x++) {
for (size_t x = 0; x < binding_count; x++) {
reset_binding_keys(&bindings[x]);
}
}
static void
add_key_to_matching_bindings(struct oxr_binding *bindings, size_t num_bindings, XrPath path, uint32_t key)
add_key_to_matching_bindings(struct oxr_binding *bindings, size_t binding_count, XrPath path, uint32_t key)
{
for (size_t x = 0; x < num_bindings; x++) {
for (size_t x = 0; x < binding_count; x++) {
struct oxr_binding *b = &bindings[x];
bool found = false;
uint32_t preferred_path_index;
for (size_t y = 0; y < b->num_paths; y++) {
for (size_t y = 0; y < b->path_count; y++) {
if (b->paths[y] == path) {
found = true;
preferred_path_index = y;
@ -170,10 +170,10 @@ add_key_to_matching_bindings(struct oxr_binding *bindings, size_t num_bindings,
continue;
}
U_ARRAY_REALLOC_OR_FREE(b->keys, uint32_t, (b->num_keys + 1));
U_ARRAY_REALLOC_OR_FREE(b->preferred_binding_path_index, uint32_t, (b->num_keys + 1));
b->preferred_binding_path_index[b->num_keys] = preferred_path_index;
b->keys[b->num_keys++] = key;
U_ARRAY_REALLOC_OR_FREE(b->keys, uint32_t, (b->key_count + 1));
U_ARRAY_REALLOC_OR_FREE(b->preferred_binding_path_index, uint32_t, (b->key_count + 1));
b->preferred_binding_path_index[b->key_count] = preferred_path_index;
b->keys[b->key_count++] = key;
}
}
@ -265,15 +265,15 @@ get_identifier_str_in_profile(struct oxr_logger *log,
return NULL;
}
for (size_t i = 0; i < oip->num_bindings; i++) {
for (size_t i = 0; i < oip->binding_count; i++) {
struct oxr_binding *binding = &oip->bindings[i];
for (size_t k = 0; k < binding->num_paths; k++) {
for (size_t k = 0; k < binding->path_count; k++) {
if (binding->paths[k] != path) {
continue;
}
str = binding->localized_name;
i = oip->num_bindings; // Break the outer loop as well.
i = oip->binding_count; // Break the outer loop as well.
break;
}
}
@ -362,10 +362,10 @@ oxr_binding_find_bindings_from_key(struct oxr_logger *log,
struct oxr_interaction_profile *p,
uint32_t key,
struct oxr_binding *bindings[OXR_MAX_BINDINGS_PER_ACTION],
size_t *num_bindings)
size_t *binding_count)
{
if (p == NULL) {
*num_bindings = 0;
*binding_count = 0;
return;
}
@ -373,10 +373,10 @@ oxr_binding_find_bindings_from_key(struct oxr_logger *log,
//! then 32 bindings.
size_t num = 0;
for (size_t y = 0; y < p->num_bindings; y++) {
for (size_t y = 0; y < p->binding_count; y++) {
struct oxr_binding *b = &p->bindings[y];
for (size_t z = 0; z < b->num_keys; z++) {
for (size_t z = 0; z < b->key_count; z++) {
if (b->keys[z] == key) {
bindings[num++] = b;
break;
@ -384,41 +384,41 @@ oxr_binding_find_bindings_from_key(struct oxr_logger *log,
}
if (num >= 32) {
*num_bindings = num;
*binding_count = num;
return;
}
}
*num_bindings = num;
*binding_count = num;
}
void
oxr_binding_destroy_all(struct oxr_logger *log, struct oxr_instance *inst)
{
for (size_t x = 0; x < inst->num_profiles; x++) {
for (size_t x = 0; x < inst->profile_count; x++) {
struct oxr_interaction_profile *p = inst->profiles[x];
for (size_t y = 0; y < p->num_bindings; y++) {
for (size_t y = 0; y < p->binding_count; y++) {
struct oxr_binding *b = &p->bindings[y];
reset_binding_keys(b);
free(b->paths);
b->paths = NULL;
b->num_paths = 0;
b->path_count = 0;
b->input = 0;
b->output = 0;
}
free(p->bindings);
p->bindings = NULL;
p->num_bindings = 0;
p->binding_count = 0;
free(p);
}
free(inst->profiles);
inst->profiles = NULL;
inst->num_profiles = 0;
inst->profile_count = 0;
}
@ -445,16 +445,16 @@ oxr_action_suggest_interaction_profile_bindings(struct oxr_logger *log,
}
struct oxr_binding *bindings = p->bindings;
size_t num_bindings = p->num_bindings;
size_t binding_count = p->binding_count;
// Everything is now valid, reset the keys.
reset_all_keys(bindings, num_bindings);
reset_all_keys(bindings, binding_count);
for (size_t i = 0; i < suggestedBindings->countSuggestedBindings; i++) {
const XrActionSuggestedBinding *s = &suggestedBindings->suggestedBindings[i];
struct oxr_action *act = XRT_CAST_OXR_HANDLE_TO_PTR(struct oxr_action *, s->action);
add_key_to_matching_bindings(bindings, num_bindings, s->binding, act->act_key);
add_key_to_matching_bindings(bindings, binding_count, s->binding, act->act_key);
}
return XR_SUCCESS;

View file

@ -90,7 +90,7 @@ oxr_action_cache_teardown(struct oxr_action_cache *cache)
for (uint32_t i = 0; i < cache->input_count; i++) {
struct oxr_action_input *action_input = &cache->inputs[i];
oxr_input_transform_destroy(&(action_input->transforms));
action_input->num_transforms = 0;
action_input->transform_count = 0;
}
free(cache->inputs);
cache->inputs = NULL;
@ -177,12 +177,12 @@ oxr_action_set_attachment_init(struct oxr_logger *log,
void
oxr_action_set_attachment_teardown(struct oxr_action_set_attachment *act_set_attached)
{
for (size_t i = 0; i < act_set_attached->num_action_attachments; ++i) {
for (size_t i = 0; i < act_set_attached->action_attachment_count; ++i) {
oxr_action_attachment_teardown(&(act_set_attached->act_attachments[i]));
}
free(act_set_attached->act_attachments);
act_set_attached->act_attachments = NULL;
act_set_attached->num_action_attachments = 0;
act_set_attached->action_attachment_count = 0;
struct oxr_session *sess = act_set_attached->sess;
u_hashmap_int_erase(sess->act_sets_attachments_by_key, act_set_attached->act_set_key);
@ -372,7 +372,7 @@ oxr_action_create(struct oxr_logger *log,
bool
oxr_classify_sub_action_paths(struct oxr_logger *log,
struct oxr_instance *inst,
uint32_t num_subaction_paths,
uint32_t subaction_path_count,
const XrPath *subaction_paths,
struct oxr_subaction_paths *subaction_paths_out)
{
@ -383,12 +383,12 @@ oxr_classify_sub_action_paths(struct oxr_logger *log,
// Reset the subaction_paths completely.
U_ZERO(subaction_paths_out);
if (num_subaction_paths == 0) {
if (subaction_path_count == 0) {
subaction_paths_out->any = true;
return ret;
}
for (uint32_t i = 0; i < num_subaction_paths; i++) {
for (uint32_t i = 0; i < subaction_path_count; i++) {
XrPath path = subaction_paths[i];
#define IDENTIFY_PATH(X) \
@ -585,7 +585,7 @@ static XrPath
get_matched_xrpath(struct oxr_binding *b, struct oxr_action *act)
{
XrPath preferred_path = XR_NULL_PATH;
for (uint32_t i = 0; i < b->num_keys; i++) {
for (uint32_t i = 0; i < b->key_count; i++) {
if (b->keys[i] == act->act_key) {
uint32_t preferred_path_index = XR_NULL_PATH;
preferred_path_index = b->preferred_binding_path_index[i];
@ -816,7 +816,7 @@ oxr_input_is_input_for_cache(struct oxr_action_input *action_input, struct oxr_a
static bool
oxr_input_is_bound_in_act_set(struct oxr_action_input *action_input, struct oxr_action_set_attachment *act_set_attached)
{
for (size_t i = 0; i < act_set_attached->num_action_attachments; i++) {
for (size_t i = 0; i < act_set_attached->action_attachment_count; i++) {
struct oxr_action_attachment *act_attached = &act_set_attached->act_attachments[i];
#define ACCUMULATE_PATHS(X) \
@ -934,7 +934,7 @@ oxr_input_combine_input(struct oxr_session *sess,
};
struct oxr_input_value_tagged transformed = {0};
if (!oxr_input_transform_process(action_input->transforms, action_input->num_transforms, &raw_input,
if (!oxr_input_transform_process(action_input->transforms, action_input->transform_count, &raw_input,
&transformed)) {
// We couldn't transform, how strange. Reset all state.
// At this level we don't know what action this is, etc.
@ -1229,7 +1229,7 @@ oxr_action_attachment_update(struct oxr_logger *log,
* Try to produce a transform chain to convert the available input into the
* desired input type.
*
* Populates @p action_input->transforms and @p action_input->num_transforms on
* Populates @p action_input->transforms and @p action_input->transform_count on
* success.
*
* @returns false if it could not, true if it could
@ -1242,7 +1242,7 @@ oxr_action_populate_input_transform(struct oxr_logger *log,
struct oxr_action_input *action_input)
{
assert(action_input->transforms == NULL);
assert(action_input->num_transforms == 0);
assert(action_input->transform_count == 0);
const char *str;
size_t length;
oxr_path_get_string(log, sess->sys->inst, action_input->bound_path, &str, &length);
@ -1250,7 +1250,7 @@ oxr_action_populate_input_transform(struct oxr_logger *log,
enum xrt_input_type t = XRT_GET_INPUT_TYPE(action_input->input->name);
return oxr_input_transform_create_chain(log, slog, t, act->data->action_type, act->data->name, str,
&action_input->transforms, &action_input->num_transforms);
&action_input->transforms, &action_input->transform_count);
}
static void
@ -1383,12 +1383,12 @@ oxr_session_attach_action_sets(struct oxr_logger *log,
// Allocate room for list. No need to check if anything has been
// attached the API function does that.
sess->num_action_set_attachments = bindInfo->countActionSets;
sess->action_set_attachment_count = bindInfo->countActionSets;
sess->act_set_attachments =
U_TYPED_ARRAY_CALLOC(struct oxr_action_set_attachment, sess->num_action_set_attachments);
U_TYPED_ARRAY_CALLOC(struct oxr_action_set_attachment, sess->action_set_attachment_count);
// Set up the per-session data for these action sets.
for (uint32_t i = 0; i < sess->num_action_set_attachments; i++) {
for (uint32_t i = 0; i < sess->action_set_attachment_count; i++) {
struct oxr_action_set *act_set =
XRT_CAST_OXR_HANDLE_TO_PTR(struct oxr_action_set *, bindInfo->actionSets[i]);
struct oxr_action_set_ref *act_set_ref = act_set->data;
@ -1397,9 +1397,9 @@ oxr_session_attach_action_sets(struct oxr_logger *log,
oxr_action_set_attachment_init(log, sess, act_set, act_set_attached);
// Allocate the action attachments for this set.
act_set_attached->num_action_attachments = oxr_handle_base_get_num_children(&act_set->handle);
act_set_attached->action_attachment_count = oxr_handle_base_get_num_children(&act_set->handle);
act_set_attached->act_attachments =
U_TYPED_ARRAY_CALLOC(struct oxr_action_attachment, act_set_attached->num_action_attachments);
U_TYPED_ARRAY_CALLOC(struct oxr_action_attachment, act_set_attached->action_attachment_count);
// Set up the per-session data for the actions.
uint32_t child_index = 0;
@ -1450,12 +1450,12 @@ oxr_action_sync_data(struct oxr_logger *log,
int64_t now = time_state_get_now(sess->sys->inst->timekeeping);
// Loop over all xdev devices.
for (size_t i = 0; i < sess->sys->num_xdevs; i++) {
for (size_t i = 0; i < sess->sys->xdev_count; i++) {
oxr_xdev_update(sess->sys->xdevs[i]);
}
// Reset all action set attachments.
for (size_t i = 0; i < sess->num_action_set_attachments; ++i) {
for (size_t i = 0; i < sess->action_set_attachment_count; ++i) {
act_set_attached = &sess->act_set_attachments[i];
U_ZERO(&act_set_attached->requested_subaction_paths);
}
@ -1483,7 +1483,7 @@ oxr_action_sync_data(struct oxr_logger *log,
#undef ACCUMULATE_REQUESTED
/* check if we have at least one action for requested subactionpath */
for (uint32_t k = 0; k < act_set_attached->num_action_attachments; k++) {
for (uint32_t k = 0; k < act_set_attached->action_attachment_count; k++) {
struct oxr_action_attachment *act_attached = &act_set_attached->act_attachments[k];
if (act_attached == NULL) {
@ -1502,12 +1502,12 @@ oxr_action_sync_data(struct oxr_logger *log,
}
// Now, update all action attachments
for (size_t i = 0; i < sess->num_action_set_attachments; ++i) {
for (size_t i = 0; i < sess->action_set_attachment_count; ++i) {
act_set_attached = &sess->act_set_attachments[i];
struct oxr_subaction_paths subaction_paths = act_set_attached->requested_subaction_paths;
for (uint32_t k = 0; k < act_set_attached->num_action_attachments; k++) {
for (uint32_t k = 0; k < act_set_attached->action_attachment_count; k++) {
struct oxr_action_attachment *act_attached = &act_set_attached->act_attachments[k];
if (act_attached == NULL) {
@ -1523,9 +1523,9 @@ oxr_action_sync_data(struct oxr_logger *log,
}
static void
add_path_to_set(XrPath path_set[OXR_MAX_BINDINGS_PER_ACTION], XrPath new_path, uint32_t *inout_num_paths)
add_path_to_set(XrPath path_set[OXR_MAX_BINDINGS_PER_ACTION], XrPath new_path, uint32_t *inout_path_count)
{
const uint32_t n = *inout_num_paths;
const uint32_t n = *inout_path_count;
// Shouldn't be full
assert(n < OXR_MAX_BINDINGS_PER_ACTION);
@ -1538,7 +1538,7 @@ add_path_to_set(XrPath path_set[OXR_MAX_BINDINGS_PER_ACTION], XrPath new_path, u
assert(path_set[i] != 0);
}
path_set[n] = new_path;
(*inout_num_paths)++;
(*inout_path_count)++;
}
XrResult
@ -1550,7 +1550,7 @@ oxr_action_enumerate_bound_sources(struct oxr_logger *log,
XrPath *sources)
{
struct oxr_action_attachment *act_attached = NULL;
uint32_t num_paths = 0;
uint32_t path_count = 0;
XrPath temp[OXR_MAX_BINDINGS_PER_ACTION] = {0};
oxr_session_get_action_attachment(sess, act_key, &act_attached);
@ -1561,19 +1561,19 @@ oxr_action_enumerate_bound_sources(struct oxr_logger *log,
#define ACCUMULATE_PATHS(X) \
if (act_attached->X.input_count > 0) { \
for (uint32_t i = 0; i < act_attached->X.input_count; i++) { \
add_path_to_set(temp, act_attached->X.inputs[i].bound_path, &num_paths); \
add_path_to_set(temp, act_attached->X.inputs[i].bound_path, &path_count); \
} \
} \
if (act_attached->X.output_count > 0) { \
for (uint32_t i = 0; i < act_attached->X.output_count; i++) { \
add_path_to_set(temp, act_attached->X.outputs[i].bound_path, &num_paths); \
add_path_to_set(temp, act_attached->X.outputs[i].bound_path, &path_count); \
} \
}
OXR_FOR_EACH_SUBACTION_PATH(ACCUMULATE_PATHS)
#undef ACCUMULATE_PATHS
OXR_TWO_CALL_HELPER(log, sourceCapacityInput, sourceCountOutput, sources, num_paths, temp,
OXR_TWO_CALL_HELPER(log, sourceCapacityInput, sourceCountOutput, sources, path_count, temp,
oxr_session_success_result(sess));
}

View file

@ -149,7 +149,7 @@ oxr_input_transform_init_bool_to_vec1(struct oxr_input_transform *transform,
bool
oxr_input_transform_process(const struct oxr_input_transform *transform,
size_t num_transforms,
size_t transform_count,
const struct oxr_input_value_tagged *input,
struct oxr_input_value_tagged *out)
{
@ -157,7 +157,7 @@ oxr_input_transform_process(const struct oxr_input_transform *transform,
return false;
}
struct oxr_input_value_tagged data = *input;
for (size_t i = 0; i < num_transforms; ++i) {
for (size_t i = 0; i < transform_count; ++i) {
const struct oxr_input_transform *xform = &(transform[i]);
switch (xform->type) {
case INPUT_TRANSFORM_IDENTITY:
@ -274,10 +274,10 @@ extend_transform_array(struct oxr_logger *log,
}
struct oxr_input_transform *
oxr_input_transform_clone_chain(struct oxr_input_transform *transforms, size_t num_transforms)
oxr_input_transform_clone_chain(struct oxr_input_transform *transforms, size_t transform_count)
{
struct oxr_input_transform *ret = U_TYPED_ARRAY_CALLOC(struct oxr_input_transform, num_transforms);
memcpy(ret, transforms, sizeof(*ret) * num_transforms);
struct oxr_input_transform *ret = U_TYPED_ARRAY_CALLOC(struct oxr_input_transform, transform_count);
memcpy(ret, transforms, sizeof(*ret) * transform_count);
return ret;
}
@ -289,7 +289,7 @@ oxr_input_transform_create_chain(struct oxr_logger *log,
const char *action_name,
const char *bound_path_string,
struct oxr_input_transform **out_transforms,
size_t *out_num_transforms)
size_t *out_transform_count)
{
struct oxr_input_transform chain[OXR_MAX_INPUT_TRANSFORMS] = {0};
@ -298,7 +298,7 @@ oxr_input_transform_create_chain(struct oxr_logger *log,
struct oxr_input_transform *current_xform = &(chain[0]);
if (!oxr_input_transform_init_root(current_xform, input_type)) {
*out_num_transforms = 0;
*out_transform_count = 0;
*out_transforms = NULL;
return false;
}
@ -308,41 +308,41 @@ oxr_input_transform_create_chain(struct oxr_logger *log,
if (identity) {
// No transform needed, just return identity to keep this alive.
*out_num_transforms = 1;
*out_transform_count = 1;
*out_transforms = oxr_input_transform_clone_chain(chain, 1);
oxr_slog(slog, "\t\t\tUsing identity transform for input.\n");
return true;
}
// We start over here.
size_t num_transforms = 0;
size_t transform_count = 0;
while (!oxr_type_matches_xrt(current_xform->result_type, result_type)) {
if (num_transforms >= OXR_MAX_INPUT_TRANSFORMS) {
if (transform_count >= OXR_MAX_INPUT_TRANSFORMS) {
// Couldn't finish the transform to the desired type.
oxr_slog(slog,
"\t\t\tSeem to have gotten into a loop, "
"trying to make a rule to transform.\n",
action_name, bound_path_string);
*out_num_transforms = 0;
*out_transform_count = 0;
*out_transforms = NULL;
return false;
}
struct oxr_input_transform *new_xform = &(chain[num_transforms]);
struct oxr_input_transform *new_xform = &(chain[transform_count]);
if (!extend_transform_array(log, slog, new_xform, current_xform, result_type, bound_path_string)) {
// Error has already been logged.
*out_num_transforms = 0;
*out_transform_count = 0;
*out_transforms = NULL;
return false;
}
num_transforms++;
transform_count++;
current_xform = new_xform;
}
*out_num_transforms = num_transforms;
*out_transforms = oxr_input_transform_clone_chain(chain, num_transforms);
*out_transform_count = transform_count;
*out_transforms = oxr_input_transform_clone_chain(chain, transform_count);
return true;
}

View file

@ -165,7 +165,7 @@ oxr_input_transform_destroy(struct oxr_input_transform **transform_ptr);
* Apply an array of input transforms.
*
* @param[in] transforms An array of input transforms
* @param[in] num_transforms The number of elements in @p transform
* @param[in] transform_count The number of elements in @p transform
* @param[in] input The input value and type
* @param[out] out The transformed value and type
*
@ -174,7 +174,7 @@ oxr_input_transform_destroy(struct oxr_input_transform **transform_ptr);
*/
bool
oxr_input_transform_process(const struct oxr_input_transform *transforms,
size_t num_transforms,
size_t transform_count,
const struct oxr_input_value_tagged *input,
struct oxr_input_value_tagged *out);
@ -286,7 +286,7 @@ oxr_input_transform_init_bool_to_vec1(struct oxr_input_transform *transform,
* @param[in] bound_path_string The path name string that has been bound.
* @param[out] out_transforms A pointer that will be populated with the output
* array's address, or NULL.
* @param[out] out_num_transforms Where to populate the array size
* @param[out] out_transform_count Where to populate the array size
* @return false if not possible
*
* @relates oxr_input_transform
@ -299,7 +299,7 @@ oxr_input_transform_create_chain(struct oxr_logger *log,
const char *action_name,
const char *bound_path_string,
struct oxr_input_transform **out_transforms,
size_t *out_num_transforms);
size_t *out_transform_count);
/*!
* @}

View file

@ -86,7 +86,7 @@ oxr_instance_destroy(struct oxr_logger *log, struct oxr_handle_base *hb)
u_hashset_destroy(&inst->action_sets.name_store);
u_hashset_destroy(&inst->action_sets.loc_store);
for (size_t i = 0; i < inst->system.num_xdevs; i++) {
for (size_t i = 0; i < inst->system.xdev_count; i++) {
oxr_xdev_destroy(&inst->system.xdevs[i]);
}
@ -273,12 +273,12 @@ oxr_instance_create(struct oxr_logger *log, const XrInstanceCreateInfo *createIn
OXR_FOR_EACH_VALID_SUBACTION_PATH(POPULATE_ROLES)
#undef POPULATE_ROLES
sys->num_xdevs = min_size_t(ARRAY_SIZE(sys->xdevs), NUM_XDEVS);
sys->xdev_count = min_size_t(ARRAY_SIZE(sys->xdevs), NUM_XDEVS);
for (uint32_t i = 0; i < sys->num_xdevs; i++) {
for (uint32_t i = 0; i < sys->xdev_count; i++) {
sys->xdevs[i] = xdevs[i];
}
for (size_t i = sys->num_xdevs; i < NUM_XDEVS; i++) {
for (size_t i = sys->xdev_count; i < NUM_XDEVS; i++) {
oxr_xdev_destroy(&xdevs[i]);
}

View file

@ -375,7 +375,7 @@ oxr_action_to_openxr(struct oxr_action *act)
bool
oxr_classify_sub_action_paths(struct oxr_logger *log,
struct oxr_instance *inst,
uint32_t num_subaction_paths,
uint32_t subaction_path_count,
const XrPath *subaction_paths,
struct oxr_subaction_paths *subaction_paths_out);
@ -547,7 +547,7 @@ oxr_binding_find_bindings_from_key(struct oxr_logger *log,
struct oxr_interaction_profile *profile,
uint32_t key,
struct oxr_binding *bindings[OXR_MAX_BINDINGS_PER_ACTION],
size_t *num_bindings);
size_t *binding_count);
/*!
* @public @memberof oxr_instance
@ -768,7 +768,7 @@ oxr_destroy_messenger(struct oxr_logger *log, struct oxr_debug_messenger *mssngr
XrResult
oxr_system_select(struct oxr_logger *log,
struct oxr_system **systems,
uint32_t num_systems,
uint32_t system_count,
XrFormFactor form_factor,
struct oxr_system **out_selected);
@ -1078,7 +1078,7 @@ struct oxr_system
struct xrt_system_compositor *xsysc;
struct xrt_device *xdevs[16];
size_t num_xdevs;
size_t xdev_count;
/* index for xdevs array */
struct
@ -1172,7 +1172,7 @@ struct oxr_instance
} event;
struct oxr_interaction_profile **profiles;
size_t num_profiles;
size_t profile_count;
struct oxr_session *sessions;
@ -1286,7 +1286,7 @@ struct oxr_session
/*!
* Length of @ref oxr_session::act_set_attachments.
*/
size_t num_action_set_attachments;
size_t action_set_attachment_count;
/*!
* A map of action set key to action set attachments.
@ -1393,7 +1393,7 @@ struct oxr_interaction_profile
const char *localized_name;
struct oxr_binding *bindings;
size_t num_bindings;
size_t binding_count;
};
/*!
@ -1402,14 +1402,14 @@ struct oxr_interaction_profile
struct oxr_binding
{
XrPath *paths;
size_t num_paths;
size_t path_count;
//! Name presented to the user.
const char *localized_name;
enum oxr_subaction_path subaction_path;
size_t num_keys;
size_t key_count;
uint32_t *keys;
//! store which entry in paths was suggested, for each action key
uint32_t *preferred_binding_path_index;
@ -1494,7 +1494,7 @@ struct oxr_action_set_attachment
/*!
* Length of @ref oxr_action_set_attachment::act_attachments.
*/
size_t num_action_attachments;
size_t action_attachment_count;
};
/*!
@ -1547,7 +1547,7 @@ struct oxr_action_input
struct xrt_device *xdev;
struct xrt_input *input;
struct oxr_input_transform *transforms;
size_t num_transforms;
size_t transform_count;
XrPath bound_path;
};
@ -1695,7 +1695,7 @@ struct oxr_swapchain
uint32_t width, height;
//! For 1 is 2D texture, greater then 1 2D array texture.
uint32_t num_array_layers;
uint32_t array_layer_count;
struct
{

View file

@ -340,7 +340,7 @@ oxr_session_locate_views(struct oxr_logger *log,
{
struct xrt_device *xdev = GET_XDEV_BY_ROLE(sess->sys, head);
struct oxr_space *baseSpc = XRT_CAST_OXR_HANDLE_TO_PTR(struct oxr_space *, viewLocateInfo->space);
uint32_t num_views = 2;
uint32_t view_count = 2;
// Does this apply for all calls?
if (!baseSpc->is_reference) {
@ -350,14 +350,14 @@ oxr_session_locate_views(struct oxr_logger *log,
// Start two call handling.
if (viewCountOutput != NULL) {
*viewCountOutput = num_views;
*viewCountOutput = view_count;
}
if (viewCapacityInput == 0) {
return oxr_session_success_result(sess);
}
if (viewCapacityInput < num_views) {
if (viewCapacityInput < view_count) {
return oxr_error(log, XR_ERROR_SIZE_INSUFFICIENT, "(viewCapacityInput == %u) need %u",
viewCapacityInput, num_views);
viewCapacityInput, view_count);
}
// End two call handling.
@ -388,7 +388,7 @@ oxr_session_locate_views(struct oxr_logger *log,
0.0f,
};
for (uint32_t i = 0; i < num_views; i++) {
for (uint32_t i = 0; i < view_count; i++) {
struct xrt_pose view_pose = XRT_POSE_IDENTITY;
// Get the per view pose from the device.
@ -581,12 +581,12 @@ oxr_session_destroy(struct oxr_logger *log, struct oxr_handle_base *hb)
XrResult ret = oxr_event_remove_session_events(log, sess);
for (size_t i = 0; i < sess->num_action_set_attachments; ++i) {
for (size_t i = 0; i < sess->action_set_attachment_count; ++i) {
oxr_action_set_attachment_teardown(&sess->act_set_attachments[i]);
}
free(sess->act_set_attachments);
sess->act_set_attachments = NULL;
sess->num_action_set_attachments = 0;
sess->action_set_attachment_count = 0;
// If we tore everything down correctly, these are empty now.
assert(sess->act_sets_attachments_by_key == NULL || u_hashmap_int_empty(sess->act_sets_attachments_by_key));

View file

@ -209,11 +209,11 @@ verify_quad_layer(struct xrt_compositor *xc,
p->x, p->y, p->z);
}
if (sc->num_array_layers <= quad->subImage.imageArrayIndex) {
if (sc->array_layer_count <= quad->subImage.imageArrayIndex) {
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
"(frameEndInfo->layers[%u]->subImage.imageArrayIndex == %u) Invalid swapchain array "
"index for quad layer (%u).",
layer_index, quad->subImage.imageArrayIndex, sc->num_array_layers);
layer_index, quad->subImage.imageArrayIndex, sc->array_layer_count);
}
if (!sc->released.yes) {
@ -277,11 +277,11 @@ verify_depth_layer(struct xrt_compositor *xc,
layer_index, i);
}
if (sc->num_array_layers <= depth->subImage.imageArrayIndex) {
if (sc->array_layer_count <= depth->subImage.imageArrayIndex) {
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
"(frameEndInfo->layers[%u]->views[%i]->next<XrCompositionLayerDepthInfoKHR>.subImage."
"imageArrayIndex == %u) Invalid swapchain array index for projection layer (%u).",
layer_index, i, depth->subImage.imageArrayIndex, sc->num_array_layers);
layer_index, i, depth->subImage.imageArrayIndex, sc->array_layer_count);
}
if (is_rect_neg(&depth->subImage.imageRect)) {
@ -354,7 +354,7 @@ verify_projection_layer(struct xrt_compositor *xc,
}
// number of depth layers must be 0 or proj->viewCount
uint32_t num_depth_layers = 0;
uint32_t depth_layer_count = 0;
// Check for valid swapchain states.
for (uint32_t i = 0; i < proj->viewCount; i++) {
@ -400,12 +400,12 @@ verify_projection_layer(struct xrt_compositor *xc,
layer_index, i);
}
if (sc->num_array_layers <= view->subImage.imageArrayIndex) {
if (sc->array_layer_count <= view->subImage.imageArrayIndex) {
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
"(frameEndInfo->layers[%u]->views[%i]->subImage."
"imageArrayIndex == %u) Invalid swapchain array "
"index for projection layer (%u).",
layer_index, i, view->subImage.imageArrayIndex, sc->num_array_layers);
layer_index, i, view->subImage.imageArrayIndex, sc->array_layer_count);
}
if (is_rect_neg(&view->subImage.imageRect)) {
@ -436,17 +436,17 @@ verify_projection_layer(struct xrt_compositor *xc,
if (ret != XR_SUCCESS) {
return ret;
}
num_depth_layers++;
depth_layer_count++;
}
#endif // XRT_FEATURE_OPENXR_LAYER_DEPTH
}
#ifdef XRT_FEATURE_OPENXR_LAYER_DEPTH
if (num_depth_layers > 0 && num_depth_layers != proj->viewCount) {
if (depth_layer_count > 0 && depth_layer_count != proj->viewCount) {
return oxr_error(
log, XR_ERROR_VALIDATION_FAILURE,
"(frameEndInfo->layers[%u] projection layer must have %u depth layers or none, but has: %u)",
layer_index, proj->viewCount, num_depth_layers);
layer_index, proj->viewCount, depth_layer_count);
}
#endif // XRT_FEATURE_OPENXR_LAYER_DEPTH
@ -486,11 +486,11 @@ verify_cube_layer(struct xrt_compositor *xc,
layer_index, q->x, q->y, q->z, q->w);
}
if (sc->num_array_layers <= cube->imageArrayIndex) {
if (sc->array_layer_count <= cube->imageArrayIndex) {
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
"(frameEndInfo->layers[%u]->imageArrayIndex == %u) Invalid swapchain array index for "
"cube layer (%u).",
layer_index, cube->imageArrayIndex, sc->num_array_layers);
layer_index, cube->imageArrayIndex, sc->array_layer_count);
}
if (!sc->released.yes) {
@ -548,11 +548,11 @@ verify_cylinder_layer(struct xrt_compositor *xc,
p->x, p->y, p->z);
}
if (sc->num_array_layers <= cylinder->subImage.imageArrayIndex) {
if (sc->array_layer_count <= cylinder->subImage.imageArrayIndex) {
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
"(frameEndInfo->layers[%u]->subImage.imageArrayIndex == %u) Invalid swapchain array "
"index for cylinder layer (%u).",
layer_index, cylinder->subImage.imageArrayIndex, sc->num_array_layers);
layer_index, cylinder->subImage.imageArrayIndex, sc->array_layer_count);
}
if (!sc->released.yes) {
@ -645,11 +645,11 @@ verify_equirect1_layer(struct xrt_compositor *xc,
p->x, p->y, p->z);
}
if (sc->num_array_layers <= equirect->subImage.imageArrayIndex) {
if (sc->array_layer_count <= equirect->subImage.imageArrayIndex) {
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
"(frameEndInfo->layers[%u]->subImage.imageArrayIndex == %u) Invalid swapchain array "
"index for equirect layer (%u).",
layer_index, equirect->subImage.imageArrayIndex, sc->num_array_layers);
layer_index, equirect->subImage.imageArrayIndex, sc->array_layer_count);
}
if (!sc->released.yes) {
@ -729,11 +729,11 @@ verify_equirect2_layer(struct xrt_compositor *xc,
p->x, p->y, p->z);
}
if (sc->num_array_layers <= equirect->subImage.imageArrayIndex) {
if (sc->array_layer_count <= equirect->subImage.imageArrayIndex) {
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
"(frameEndInfo->layers[%u]->subImage.imageArrayIndex == %u) Invalid swapchain array "
"index for equirect layer (%u).",
layer_index, equirect->subImage.imageArrayIndex, sc->num_array_layers);
layer_index, equirect->subImage.imageArrayIndex, sc->array_layer_count);
}
if (!sc->released.yes) {
@ -918,8 +918,8 @@ submit_projection_layer(struct oxr_session *sess,
enum xrt_layer_composition_flags flags = convert_layer_flags(proj->layerFlags);
uint32_t num_chains = ARRAY_SIZE(scs);
for (uint32_t i = 0; i < num_chains; i++) {
uint32_t swapchain_count = ARRAY_SIZE(scs);
for (uint32_t i = 0; i < swapchain_count; i++) {
scs[i] = XRT_CAST_OXR_HANDLE_TO_PTR(struct oxr_swapchain *, proj->views[i].subImage.swapchain);
pose_ptr = (struct xrt_pose *)&proj->views[i].pose;

View file

@ -227,7 +227,7 @@ oxr_create_swapchain(struct oxr_logger *log,
sc->swapchain = xsc;
sc->width = createInfo->width;
sc->height = createInfo->height;
sc->num_array_layers = createInfo->arraySize;
sc->array_layer_count = createInfo->arraySize;
sc->acquire_image = oxr_swapchain_acquire_image;
sc->wait_image = oxr_swapchain_wait_image;
sc->release_image = oxr_swapchain_release_image;

View file

@ -35,17 +35,17 @@ oxr_system_matches(struct oxr_logger *log, struct oxr_system *sys, XrFormFactor
XrResult
oxr_system_select(struct oxr_logger *log,
struct oxr_system **systems,
uint32_t num_systems,
uint32_t system_count,
XrFormFactor form_factor,
struct oxr_system **out_selected)
{
if (num_systems == 0) {
if (system_count == 0) {
return oxr_error(log, XR_ERROR_FORM_FACTOR_UNSUPPORTED,
"(getInfo->formFactor) no system available (given: %i)", form_factor);
}
struct oxr_system *selected = NULL;
for (uint32_t i = 0; i < num_systems; i++) {
for (uint32_t i = 0; i < system_count; i++) {
if (oxr_system_matches(log, systems[i], form_factor)) {
selected = systems[i];
break;

View file

@ -111,15 +111,15 @@ static const char *required_vk_device_extensions[] = {
static void
find_to_add(char const *const *enabled,
uint32_t num_enabled,
uint32_t enabled_count,
const char **required,
uint32_t num_required,
uint32_t required_count,
const char **to_add,
uint32_t *num_to_add)
uint32_t *to_add_count)
{
for (uint32_t i = 0; i < num_required; i++) {
for (uint32_t i = 0; i < required_count; i++) {
bool already_in_list = false;
for (uint32_t j = 0; j < num_enabled; j++) {
for (uint32_t j = 0; j < enabled_count; j++) {
if (strcmp(enabled[j], required[i]) == 0) {
already_in_list = true;
break;
@ -127,7 +127,7 @@ find_to_add(char const *const *enabled,
}
if (!already_in_list) {
to_add[(*num_to_add)++] = required[i];
to_add[(*to_add_count)++] = required[i];
}
}
}
@ -135,37 +135,37 @@ find_to_add(char const *const *enabled,
static bool
extend_instance_extensions(struct oxr_logger *log, VkInstanceCreateInfo *create_info)
{
uint32_t num_required = ARRAY_SIZE(required_vk_instance_extensions);
uint32_t required_count = ARRAY_SIZE(required_vk_instance_extensions);
uint32_t num_to_add = 0;
uint32_t to_add_count = 0;
const char *to_add[ARRAY_SIZE(required_vk_instance_extensions)];
uint32_t num_enabled = create_info->enabledExtensionCount;
uint32_t enabled_count = create_info->enabledExtensionCount;
char const *const *enabled = create_info->ppEnabledExtensionNames;
find_to_add(enabled, num_enabled, required_vk_instance_extensions, num_required, to_add, &num_to_add);
find_to_add(enabled, enabled_count, required_vk_instance_extensions, required_count, to_add, &to_add_count);
enum u_logging_level ll = debug_get_log_option_compositor_log();
if (num_to_add == 0) {
if (to_add_count == 0) {
if (ll <= U_LOGGING_DEBUG) {
oxr_log(log, "App enabled all required instance exts");
}
return false;
}
uint32_t total = num_enabled + num_to_add;
uint32_t total = enabled_count + to_add_count;
char const **new_enabled = malloc(sizeof(char *) * total);
for (uint32_t i = 0; i < num_enabled; i++) {
for (uint32_t i = 0; i < enabled_count; i++) {
new_enabled[i] = enabled[i];
if (ll <= U_LOGGING_DEBUG) {
oxr_log(log, "Instance ext (app): %s", enabled[i]);
}
}
for (uint32_t i = 0; i < num_to_add; i++) {
new_enabled[num_enabled + i] = to_add[i];
for (uint32_t i = 0; i < to_add_count; i++) {
new_enabled[enabled_count + i] = to_add[i];
if (ll <= U_LOGGING_DEBUG) {
oxr_log(log, "Instance ext (rt): %s", to_add[i]);
}
@ -180,37 +180,37 @@ extend_instance_extensions(struct oxr_logger *log, VkInstanceCreateInfo *create_
static bool
extend_device_extensions(struct oxr_logger *log, VkDeviceCreateInfo *create_info)
{
uint32_t num_required = ARRAY_SIZE(required_vk_device_extensions);
uint32_t required_count = ARRAY_SIZE(required_vk_device_extensions);
uint32_t num_to_add = 0;
uint32_t to_add_count = 0;
const char *to_add[ARRAY_SIZE(required_vk_device_extensions)];
uint32_t num_enabled = create_info->enabledExtensionCount;
uint32_t enabled_count = create_info->enabledExtensionCount;
char const *const *enabled = create_info->ppEnabledExtensionNames;
find_to_add(enabled, num_enabled, required_vk_device_extensions, num_required, to_add, &num_to_add);
find_to_add(enabled, enabled_count, required_vk_device_extensions, required_count, to_add, &to_add_count);
enum u_logging_level ll = debug_get_log_option_compositor_log();
if (num_to_add == 0) {
if (to_add_count == 0) {
if (ll <= U_LOGGING_DEBUG) {
oxr_log(log, "App enabled all required device exts");
}
return false;
}
uint32_t total = num_enabled + num_to_add;
uint32_t total = enabled_count + to_add_count;
char const **new_enabled = malloc(sizeof(char *) * total);
for (uint32_t i = 0; i < num_enabled; i++) {
for (uint32_t i = 0; i < enabled_count; i++) {
new_enabled[i] = enabled[i];
if (ll <= U_LOGGING_DEBUG) {
oxr_log(log, "Device ext (app): %s", enabled[i]);
}
}
for (uint32_t i = 0; i < num_to_add; i++) {
new_enabled[num_enabled + i] = to_add[i];
for (uint32_t i = 0; i < to_add_count; i++) {
new_enabled[enabled_count + i] = to_add[i];
if (ll <= U_LOGGING_DEBUG) {
oxr_log(log, "Device ext (rt): %s", to_add[i]);
}

View file

@ -85,7 +85,7 @@ static int
p_dump(struct xrt_prober *xp);
static int
p_select_device(struct xrt_prober *xp, struct xrt_device **xdevs, size_t num_xdevs);
p_select_device(struct xrt_prober *xp, struct xrt_device **xdevs, size_t xdev_count);
static int
p_open_hid_interface(struct xrt_prober *xp,
@ -614,18 +614,18 @@ teardown(struct prober *p)
static void
handle_found_device(
struct prober *p, struct xrt_device **xdevs, size_t num_xdevs, bool *have_hmd, struct xrt_device *xdev)
struct prober *p, struct xrt_device **xdevs, size_t xdev_count, bool *have_hmd, struct xrt_device *xdev)
{
P_DEBUG(p, "Found '%s' %p", xdev->str, (void *)xdev);
size_t i = 0;
for (; i < num_xdevs; i++) {
for (; i < xdev_count; i++) {
if (xdevs[i] == NULL) {
break;
}
}
if (i + 1 > num_xdevs) {
if (i + 1 > xdev_count) {
P_ERROR(p, "Too many devices, closing '%s'", xdev->str);
xdev->destroy(xdev);
return;
@ -644,7 +644,7 @@ handle_found_device(
}
static void
add_from_devices(struct prober *p, struct xrt_device **xdevs, size_t num_xdevs, bool *have_hmd)
add_from_devices(struct prober *p, struct xrt_device **xdevs, size_t xdev_count, bool *have_hmd)
{
// Build a list of all current probed devices.
struct xrt_prober_device **dev_list = U_TYPED_ARRAY_CALLOC(struct xrt_prober_device *, p->num_devices);
@ -690,7 +690,7 @@ add_from_devices(struct prober *p, struct xrt_device **xdevs, size_t num_xdevs,
num_found, created_idx);
continue;
}
handle_found_device(p, xdevs, num_xdevs, have_hmd, new_xdevs[created_idx]);
handle_found_device(p, xdevs, xdev_count, have_hmd, new_xdevs[created_idx]);
}
}
}
@ -700,7 +700,7 @@ add_from_devices(struct prober *p, struct xrt_device **xdevs, size_t num_xdevs,
}
static void
add_from_auto_probers(struct prober *p, struct xrt_device **xdevs, size_t num_xdevs, bool *have_hmd)
add_from_auto_probers(struct prober *p, struct xrt_device **xdevs, size_t xdev_count, bool *have_hmd)
{
for (int i = 0; i < MAX_AUTO_PROBERS && p->auto_probers[i]; i++) {
@ -739,15 +739,15 @@ add_from_auto_probers(struct prober *p, struct xrt_device **xdevs, size_t num_xd
p->auto_probers[i]->name, num_found, created_idx);
continue;
}
handle_found_device(p, xdevs, num_xdevs, have_hmd, new_xdevs[created_idx]);
handle_found_device(p, xdevs, xdev_count, have_hmd, new_xdevs[created_idx]);
}
}
}
static void
add_from_remote(struct prober *p, struct xrt_device **xdevs, size_t num_xdevs, bool *have_hmd)
add_from_remote(struct prober *p, struct xrt_device **xdevs, size_t xdev_count, bool *have_hmd)
{
if (num_xdevs < 3) {
if (xdev_count < 3) {
return;
}
@ -763,13 +763,13 @@ add_from_remote(struct prober *p, struct xrt_device **xdevs, size_t num_xdevs, b
}
static void
apply_tracking_override(struct prober *p, struct xrt_device **xdevs, size_t num_xdevs, struct xrt_tracking_override *o)
apply_tracking_override(struct prober *p, struct xrt_device **xdevs, size_t xdev_count, struct xrt_tracking_override *o)
{
struct xrt_device *target_xdev = NULL;
size_t target_idx = 0;
struct xrt_device *tracker_xdev = NULL;
for (size_t i = 0; i < num_xdevs; i++) {
for (size_t i = 0; i < xdev_count; i++) {
struct xrt_device *xdev = xdevs[i];
if (xdev == NULL) {
continue;
@ -872,7 +872,7 @@ p_dump(struct xrt_prober *xp)
}
static int
p_select_device(struct xrt_prober *xp, struct xrt_device **xdevs, size_t num_xdevs)
p_select_device(struct xrt_prober *xp, struct xrt_device **xdevs, size_t xdev_count)
{
XRT_TRACE_MARKER();
@ -885,16 +885,16 @@ p_select_device(struct xrt_prober *xp, struct xrt_device **xdevs, size_t num_xde
switch (active) {
case U_ACTIVE_CONFIG_NONE:
case U_ACTIVE_CONFIG_TRACKING:
add_from_devices(p, xdevs, num_xdevs, &have_hmd);
add_from_auto_probers(p, xdevs, num_xdevs, &have_hmd);
add_from_devices(p, xdevs, xdev_count, &have_hmd);
add_from_auto_probers(p, xdevs, xdev_count, &have_hmd);
break;
case U_ACTIVE_CONFIG_REMOTE: add_from_remote(p, xdevs, num_xdevs, &have_hmd); break;
case U_ACTIVE_CONFIG_REMOTE: add_from_remote(p, xdevs, xdev_count, &have_hmd); break;
default: assert(false);
}
// It's easier if we just put the first hmd first,
// but keep other internal ordering of devices.
for (size_t i = 1; i < num_xdevs; i++) {
for (size_t i = 1; i < xdev_count; i++) {
if (xdevs[i] == NULL) {
continue;
}
@ -916,7 +916,7 @@ p_select_device(struct xrt_prober *xp, struct xrt_device **xdevs, size_t num_xde
if (u_config_json_get_tracking_overrides(&p->json, overrides, &num_overrides)) {
for (size_t i = 0; i < num_overrides; i++) {
struct xrt_tracking_override *o = &overrides[i];
apply_tracking_override(p, xdevs, num_xdevs, o);
apply_tracking_override(p, xdevs, xdev_count, o);
}
}
@ -929,7 +929,7 @@ p_select_device(struct xrt_prober *xp, struct xrt_device **xdevs, size_t num_xde
// Even if we've found some controllers, we don't use them without an
// HMD. So, destroy all other found devices.
for (size_t i = 1; i < num_xdevs; i++) {
for (size_t i = 1; i < xdev_count; i++) {
if (xdevs[i] == NULL) {
continue;
}

View file

@ -408,7 +408,7 @@ public:
return;
}
for (size_t i = 0; i < p->num_bindings; i++) {
for (size_t i = 0; i < p->binding_count; i++) {
struct binding_template *b = &p->bindings[i];
if (b->input != 0) {

View file

@ -49,7 +49,7 @@ t_instance(struct xrt_instance *xinst)
*/
static int
t_instance_select(struct xrt_instance *xinst, struct xrt_device **xdevs, size_t num_xdevs)
t_instance_select(struct xrt_instance *xinst, struct xrt_device **xdevs, size_t xdev_count)
{
struct t_instance *tinst = t_instance(xinst);
@ -58,7 +58,7 @@ t_instance_select(struct xrt_instance *xinst, struct xrt_device **xdevs, size_t
return ret;
}
return xrt_prober_select(tinst->xp, xdevs, num_xdevs);
return xrt_prober_select(tinst->xp, xdevs, xdev_count);
}
static int

View file

@ -23,7 +23,7 @@ TEST_CASE("input_transform")
struct oxr_sink_logger slog = {};
struct oxr_input_transform *transforms = NULL;
size_t num_transforms = 0;
size_t transform_count = 0;
oxr_input_value_tagged input = {};
oxr_input_value_tagged output = {};
@ -37,10 +37,10 @@ TEST_CASE("input_transform")
input.type = XRT_INPUT_TYPE_VEC1_MINUS_ONE_TO_ONE;
CHECK(oxr_input_transform_create_chain(&log, &slog, input.type, action_type, "float_action",
"/dummy_float", &transforms, &num_transforms));
"/dummy_float", &transforms, &transform_count));
// Just identity
CHECK(num_transforms == 1);
CHECK(transform_count == 1);
CHECK(transforms != nullptr);
SECTION("Roundtrip")
@ -48,7 +48,7 @@ TEST_CASE("input_transform")
auto value = GENERATE(values({-1.f, -0.5f, 0.f, -0.f, 0.5f, 1.f}));
input.value.vec1.x = value;
CHECK(oxr_input_transform_process(transforms, num_transforms, &input, &output));
CHECK(oxr_input_transform_process(transforms, transform_count, &input, &output));
CHECK(input.value.vec1.x == output.value.vec1.x);
}
}
@ -58,10 +58,10 @@ TEST_CASE("input_transform")
input.type = XRT_INPUT_TYPE_VEC1_ZERO_TO_ONE;
CHECK(oxr_input_transform_create_chain(&log, &slog, input.type, action_type, "float_action",
"/dummy_float", &transforms, &num_transforms));
"/dummy_float", &transforms, &transform_count));
// Just identity
CHECK(num_transforms == 1);
CHECK(transform_count == 1);
CHECK(transforms != nullptr);
SECTION("Roundtrip")
@ -69,7 +69,7 @@ TEST_CASE("input_transform")
auto value = GENERATE(values({0.f, -0.f, 0.5f, 1.f}));
input.value.vec1.x = value;
CHECK(oxr_input_transform_process(transforms, num_transforms, &input, &output));
CHECK(oxr_input_transform_process(transforms, transform_count, &input, &output));
CHECK(input.value.vec1.x == output.value.vec1.x);
}
}
@ -84,13 +84,13 @@ TEST_CASE("input_transform")
{
CHECK(oxr_input_transform_create_chain(&log, &slog, input.type, action_type,
"float_action", "/dummy_vec2/x", &transforms,
&num_transforms));
&transform_count));
// A get-x
CHECK(num_transforms == 1);
CHECK(transform_count == 1);
CHECK(transforms != nullptr);
CHECK(oxr_input_transform_process(transforms, num_transforms, &input, &output));
CHECK(oxr_input_transform_process(transforms, transform_count, &input, &output));
CHECK(input.value.vec2.x == output.value.vec1.x);
}
@ -98,13 +98,13 @@ TEST_CASE("input_transform")
{
CHECK(oxr_input_transform_create_chain(&log, &slog, input.type, action_type,
"float_action", "/dummy_vec2/y", &transforms,
&num_transforms));
&transform_count));
// A get-y
CHECK(num_transforms == 1);
CHECK(transform_count == 1);
CHECK(transforms != nullptr);
CHECK(oxr_input_transform_process(transforms, num_transforms, &input, &output));
CHECK(oxr_input_transform_process(transforms, transform_count, &input, &output));
CHECK(input.value.vec2.y == output.value.vec1.x);
}
@ -112,14 +112,14 @@ TEST_CASE("input_transform")
{
CHECK_FALSE(oxr_input_transform_create_chain(&log, &slog, input.type, action_type,
"float_action", "/dummy_vec2", &transforms,
&num_transforms));
&transform_count));
// Shouldn't make a transform, not possible
CHECK(num_transforms == 0);
CHECK(transform_count == 0);
CHECK(transforms == nullptr);
// shouldn't do anything, but shouldn't explode.
CHECK_FALSE(oxr_input_transform_process(transforms, num_transforms, &input, &output));
CHECK_FALSE(oxr_input_transform_process(transforms, transform_count, &input, &output));
}
}
@ -127,17 +127,17 @@ TEST_CASE("input_transform")
{
input.type = XRT_INPUT_TYPE_BOOLEAN;
CHECK(oxr_input_transform_create_chain(&log, &slog, input.type, action_type, "float_action",
"/dummy_bool", &transforms, &num_transforms));
"/dummy_bool", &transforms, &transform_count));
// A bool-to-float
CHECK(num_transforms == 1);
CHECK(transform_count == 1);
CHECK(transforms != nullptr);
SECTION("False")
{
input.value.boolean = false;
CHECK(oxr_input_transform_process(transforms, num_transforms, &input, &output));
CHECK(oxr_input_transform_process(transforms, transform_count, &input, &output));
CHECK(0.0f == output.value.vec1.x);
}
@ -145,7 +145,7 @@ TEST_CASE("input_transform")
{
input.value.boolean = true;
CHECK(oxr_input_transform_process(transforms, num_transforms, &input, &output));
CHECK(oxr_input_transform_process(transforms, transform_count, &input, &output));
CHECK(1.0f == output.value.vec1.x);
}
}
@ -159,15 +159,15 @@ TEST_CASE("input_transform")
input.type = XRT_INPUT_TYPE_BOOLEAN;
CHECK(oxr_input_transform_create_chain(&log, &slog, input.type, action_type, "bool_action",
"/dummy_bool", &transforms, &num_transforms));
CHECK(num_transforms == 1);
"/dummy_bool", &transforms, &transform_count));
CHECK(transform_count == 1);
CHECK(transforms != nullptr);
SECTION("Roundtrip")
{
auto value = GENERATE(values({0, 1}));
input.value.boolean = bool(value);
CHECK(oxr_input_transform_process(transforms, num_transforms, &input, &output));
CHECK(oxr_input_transform_process(transforms, transform_count, &input, &output));
CHECK(input.value.boolean == output.value.boolean);
}
}
@ -177,8 +177,8 @@ TEST_CASE("input_transform")
input.type = XRT_INPUT_TYPE_VEC1_MINUS_ONE_TO_ONE;
CHECK(oxr_input_transform_create_chain(&log, &slog, input.type, action_type, "bool_action",
"/dummy_float", &transforms, &num_transforms));
CHECK(num_transforms == 1);
"/dummy_float", &transforms, &transform_count));
CHECK(transform_count == 1);
CHECK(transforms != nullptr);
SECTION("True")
@ -186,7 +186,7 @@ TEST_CASE("input_transform")
auto value = GENERATE(values({0.5f, 1.f}));
input.value.vec1.x = value;
CHECK(oxr_input_transform_process(transforms, num_transforms, &input, &output));
CHECK(oxr_input_transform_process(transforms, transform_count, &input, &output));
CHECK(output.value.boolean == true);
}
@ -195,7 +195,7 @@ TEST_CASE("input_transform")
auto value = GENERATE(values({0.0f, -1.f}));
input.value.vec1.x = value;
CHECK(oxr_input_transform_process(transforms, num_transforms, &input, &output));
CHECK(oxr_input_transform_process(transforms, transform_count, &input, &output));
CHECK(output.value.boolean == false);
}
}
@ -205,9 +205,9 @@ TEST_CASE("input_transform")
input.type = XRT_INPUT_TYPE_VEC1_ZERO_TO_ONE;
CHECK(oxr_input_transform_create_chain(&log, &slog, input.type, action_type, "bool_action",
"/dummy_float", &transforms, &num_transforms));
"/dummy_float", &transforms, &transform_count));
// A bool to float
CHECK(num_transforms == 1);
CHECK(transform_count == 1);
CHECK(transforms != nullptr);
SECTION("True")
@ -215,7 +215,7 @@ TEST_CASE("input_transform")
auto value = GENERATE(values({0.95f, 1.f}));
input.value.vec1.x = value;
CHECK(oxr_input_transform_process(transforms, num_transforms, &input, &output));
CHECK(oxr_input_transform_process(transforms, transform_count, &input, &output));
CHECK(output.value.boolean == true);
}
@ -224,7 +224,7 @@ TEST_CASE("input_transform")
auto value = GENERATE(values({0.0f, 0.5f}));
input.value.vec1.x = value;
CHECK(oxr_input_transform_process(transforms, num_transforms, &input, &output));
CHECK(oxr_input_transform_process(transforms, transform_count, &input, &output));
CHECK(output.value.boolean == false);
}
}
@ -239,11 +239,11 @@ TEST_CASE("input_transform")
{
CHECK(oxr_input_transform_create_chain(&log, &slog, input.type, action_type,
"float_action", "/dummy_vec2/x", &transforms,
&num_transforms));
CHECK(num_transforms == 2);
&transform_count));
CHECK(transform_count == 2);
CHECK(transforms != nullptr);
CHECK(oxr_input_transform_process(transforms, num_transforms, &input, &output));
CHECK(oxr_input_transform_process(transforms, transform_count, &input, &output));
CHECK(false == output.value.boolean);
}
@ -251,11 +251,11 @@ TEST_CASE("input_transform")
{
CHECK(oxr_input_transform_create_chain(&log, &slog, input.type, action_type,
"float_action", "/dummy_vec2/y", &transforms,
&num_transforms));
CHECK(num_transforms == 2);
&transform_count));
CHECK(transform_count == 2);
CHECK(transforms != nullptr);
CHECK(oxr_input_transform_process(transforms, num_transforms, &input, &output));
CHECK(oxr_input_transform_process(transforms, transform_count, &input, &output));
CHECK(true == output.value.boolean);
}
@ -263,14 +263,14 @@ TEST_CASE("input_transform")
{
CHECK_FALSE(oxr_input_transform_create_chain(&log, &slog, input.type, action_type,
"float_action", "/dummy", &transforms,
&num_transforms));
&transform_count));
// Shouldn't make a transform, not possible
CHECK(num_transforms == 0);
CHECK(transform_count == 0);
CHECK(transforms == nullptr);
// shouldn't do anything, but shouldn't explode.
CHECK_FALSE(oxr_input_transform_process(transforms, num_transforms, &input, &output));
CHECK_FALSE(oxr_input_transform_process(transforms, transform_count, &input, &output));
}
}
}
@ -283,9 +283,9 @@ TEST_CASE("input_transform")
{
input.type = XRT_INPUT_TYPE_POSE;
CHECK(oxr_input_transform_create_chain(&log, &slog, input.type, action_type, "pose_action",
"/dummy_pose", &transforms, &num_transforms));
"/dummy_pose", &transforms, &transform_count));
// Identity, just so this binding doesn't get culled.
CHECK(num_transforms == 1);
CHECK(transform_count == 1);
}
SECTION("From other input")
@ -303,10 +303,10 @@ TEST_CASE("input_transform")
CHECK_FALSE(oxr_input_transform_create_chain(&log, &slog, input.type, action_type,
"pose_action", "/dummy", &transforms,
&num_transforms));
&transform_count));
// not possible
CHECK(num_transforms == 0);
CHECK(transform_count == 0);
CHECK(transforms == nullptr);
}
}