Skip to content

Commit

Permalink
Add natvis widget to info page
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Jan 30, 2025
1 parent 04134b8 commit c7c7ba9
Show file tree
Hide file tree
Showing 8 changed files with 255 additions and 114 deletions.
258 changes: 162 additions & 96 deletions deps/flecs.c

Large diffs are not rendered by default.

57 changes: 43 additions & 14 deletions deps/flecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3825,6 +3825,13 @@ typedef struct ecs_iter_private_t {
ecs_iter_cache_t cache; /* Inline arrays to reduce allocations */
} ecs_iter_private_t;

/* Data structures that store the command queue */
typedef struct ecs_commands_t {
ecs_vec_t queue;
ecs_stack_t stack; /* Temp memory used by deferred commands */
ecs_sparse_t entries; /* <entity, op_entry_t> - command batching */
} ecs_commands_t;

#ifdef __cplusplus
}
#endif
Expand Down Expand Up @@ -3972,6 +3979,42 @@ FLECS_API
char* flecs_to_snake_case(
const char *str);

/* Suspend/resume readonly state. To fully support implicit registration of
* components, it should be possible to register components while the world is
* in readonly mode. It is not uncommon that a component is used first from
* within a system, which are often ran while in readonly mode.
*
* Suspending readonly mode is only allowed when the world is not multithreaded.
* When a world is multithreaded, it is not safe to (even temporarily) leave
* readonly mode, so a multithreaded application should always explicitly
* register components in advance.
*
* These operations also suspend deferred mode.
*
* Functions are public to support language bindings.
*/
typedef struct ecs_suspend_readonly_state_t {
bool is_readonly;
bool is_deferred;
bool cmd_flushing;
int32_t defer_count;
ecs_entity_t scope;
ecs_entity_t with;
ecs_commands_t cmd_stack[2];
ecs_commands_t *cmd;
ecs_stage_t *stage;
} ecs_suspend_readonly_state_t;

FLECS_API
ecs_world_t* flecs_suspend_readonly(
const ecs_world_t *world,
ecs_suspend_readonly_state_t *state);

FLECS_API
void flecs_resume_readonly(
ecs_world_t *world,
ecs_suspend_readonly_state_t *state);

FLECS_DBG_API
int32_t flecs_table_observed_count(
const ecs_table_t *table);
Expand Down Expand Up @@ -25505,20 +25548,6 @@ struct entity_builder : entity_view {
* Emplace constructs a component in the storage, which prevents calling the
* destructor on the value passed into the function.
*
* Emplace attempts the following signatures to construct the component:
*
* @code
* T{Args...}
* T{flecs::entity, Args...}
* @endcode
*
* If the second signature matches, emplace will pass in the current entity
* as argument to the constructor, which is useful if the component needs
* to be aware of the entity to which it has been added.
*
* Emplace may only be called for components that have not yet been added
* to the entity.
*
* @tparam T the component to emplace
* @param args The arguments to pass to the constructor of T
*/
Expand Down
2 changes: 1 addition & 1 deletion etc/flecs_explorer.js

Large diffs are not rendered by default.

Binary file modified etc/flecs_explorer.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions etc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@

<template v-if="app_params.page == 'info'">
<page-info
:conn="conn"
v-model:app_params="app_params"
:app_state="app_state">
</page-info>
Expand Down
3 changes: 2 additions & 1 deletion etc/js/components/pages/info/page.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div id="page-info" class="page-content">
<pane-info :app_state="app_state"></pane-info>
<pane-info :conn="conn" :app_state="app_state"></pane-info>
</div>
</template>

Expand All @@ -12,6 +12,7 @@ export default { name: "page-info" };
import { defineProps } from 'vue';
const props = defineProps({
conn: {type: Object, required: true},
app_params: {type: Object, required: true},
app_state: {type: Object, required: true}
});
Expand Down
46 changes: 45 additions & 1 deletion etc/js/components/pages/info/pane-info.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
<div class="info-addons">
<div v-for="(addon, i) in addons" :class="css_addon(i)">{{ addon }}</div>
</div>

<p>Natvis</p>
<div class="info-natvis">
<pre>{{ natvisXml }}</pre>
</div>
</div>
</template>

Expand All @@ -75,12 +80,45 @@ export default {
</script>

<script setup>
import { defineProps, computed } from 'vue';
import { defineProps, ref, computed, onMounted } from 'vue';
const props = defineProps({
conn: {type: Object, required: true},
app_state: {type: Object, required: true },
});
const componentQueryResult = ref({results: []});
onMounted(() => {
props.conn.query("Component, (Identifier, Symbol), !flecs.meta.primitive", {}, (reply) => {
componentQueryResult.value = reply;
});
});
const natvisXml = computed(() => {
let xml = "";
for (const r of componentQueryResult.value.results) {
const size = r.fields.values[0].size;
if (size === 0) {
continue;
}
const name = r.name;
let path = name;
if (r.parent) {
path = r.parent + "." + name;
}
let symbol = r.fields.values[1].value;
symbol = symbol.replaceAll(".", "::");
xml += `<Item Name="${name}" Condition='!strcmp(ComponentName, "${path}")'>*(${symbol}*)Ptr</Item>\n`;
}
return xml;
});
const css_addon = (i) => {
if (!(i % 2)) {
return "info-addon";
Expand Down Expand Up @@ -228,4 +266,10 @@ div.info-addons {
padding-top: 0.5rem;
padding-bottom: 0.5rem;
}
div.info-natvis {
display: grid;
overflow: hidden;
}
</style>
2 changes: 1 addition & 1 deletion etc/sokol/shaders/fx_ssao_header.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Based on https://threejs.org/examples/webgl_postprocessing_sao.html

// Increase/decrease to trade quality for performance
#define NUM_SAMPLES 3
#define NUM_SAMPLES 1
// The sample kernel uses a spiral pattern so most samples are concentrated
// close to the center.
#define NUM_RINGS 3
Expand Down

0 comments on commit c7c7ba9

Please sign in to comment.