Fix a few issues with the passive viewer.
1. Create an arena for the mjData instance used by the passive viewer visualization. When using the passive viewer, stuff gets copied from the real mjData into a minimal struct. That struct didn't have a stack, and now visualization for Flex does stack allocs. 2. Add missing a missing field in scene state for flex visualization. 3. Fix a memory leak where mjvScene wasn't released on exit in the passive viewer. 4. Add some locks in places where the render thread and Simulate::Sync collide. This fixes #1280. PiperOrigin-RevId: 591891676 Change-Id: I592f286cab9719c8d9af84e42f9756ea1f9f1971
This commit is contained in:
committed by
Copybara-Service
parent
8ecb16abfa
commit
7cb7c87f70
@@ -86,6 +86,11 @@ void mjv_makeSceneState(const mjModel* m, const mjData* d, mjvSceneState* scnsta
|
||||
#undef XMJV
|
||||
#undef X
|
||||
|
||||
// create an arena in the scnstate, to allow visualization code to use the stack.
|
||||
// TODO: Consider allocating way less than narena, since stack allocations in
|
||||
// visualization code are much smaller than the arena space required by the model,
|
||||
// typically.
|
||||
scnstate->nbuffer += roundUpToCacheLine(m->narena);
|
||||
// buffer space required for contacts
|
||||
int condimmax = mj_isPyramidal(m) ? 10 : 6;
|
||||
scnstate->nbuffer += roundUpToCacheLine(sizeof(*d->contact) * maxgeom);
|
||||
@@ -118,6 +123,10 @@ void mjv_makeSceneState(const mjModel* m, const mjData* d, mjvSceneState* scnsta
|
||||
#undef XMJV
|
||||
#undef X
|
||||
|
||||
scnstate->model.narena = m->narena;
|
||||
scnstate->data.arena = (void*)ptr;
|
||||
ptr += roundUpToCacheLine(m->narena);
|
||||
|
||||
scnstate->data.contact = (mjContact*)ptr;
|
||||
ptr += roundUpToCacheLine(sizeof(*scnstate->data.contact) * scnstate->maxgeom);
|
||||
|
||||
@@ -177,6 +186,7 @@ void mjv_assignFromSceneState(const mjvSceneState* scnstate, mjModel* m, mjData*
|
||||
m->opt = scnstate->model.opt;
|
||||
m->vis = scnstate->model.vis;
|
||||
m->stat = scnstate->model.stat;
|
||||
m->narena = scnstate->model.narena;
|
||||
|
||||
#define X(dtype, var, dim0, dim1)
|
||||
#define XMJV(dtype, var, dim0, dim1) m->var = scnstate->model.var;
|
||||
@@ -194,10 +204,16 @@ void mjv_assignFromSceneState(const mjvSceneState* scnstate, mjModel* m, mjData*
|
||||
#endif
|
||||
|
||||
memcpy(d->warning, scnstate->data.warning, sizeof(d->warning));
|
||||
d->threadpool = 0;
|
||||
d->nefc = scnstate->data.nefc;
|
||||
d->ncon = scnstate->data.ncon;
|
||||
d->nisland = scnstate->data.nisland;
|
||||
d->time = scnstate->data.time;
|
||||
d->narena = scnstate->model.narena;
|
||||
d->arena = scnstate->data.arena;
|
||||
d->parena = 0;
|
||||
d->pbase = 0;
|
||||
d->pstack = 0;
|
||||
|
||||
#define X(dtype, var, dim0, dim1)
|
||||
#define XMJV(dtype, var, dim0, dim1) d->var = scnstate->data.var;
|
||||
|
||||
Reference in New Issue
Block a user