Skip to content

Commit 1e1cc3f

Browse files
authored
Merge pull request #171 from leod/clear_trace_cache
Clear `Trace` cache after transpilation
2 parents bdee928 + 7586ebf commit 1e1cc3f

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/sl/dag/trace.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ impl Trace {
2222
Trace::Id(id)
2323
}
2424

25-
pub(crate) const fn c(f: fn() -> Rc<Expr>) -> Self {
26-
Trace::Const(f)
27-
}
28-
2925
pub fn expr(&self) -> Rc<Expr> {
3026
use Trace::*;
3127

@@ -34,6 +30,14 @@ impl Trace {
3430
Const(f) => f(),
3531
}
3632
}
33+
34+
pub(crate) const fn c(f: fn() -> Rc<Expr>) -> Self {
35+
Trace::Const(f)
36+
}
37+
38+
pub(crate) fn clear_cache() {
39+
REGISTRY.with(|reg| *reg.borrow_mut() = Registry::default());
40+
}
3741
}
3842

3943
#[derive(Default)]

src/sl/transpile.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212

1313
use super::{
1414
codegen,
15-
dag::{Expr, SamplerType, Type},
15+
dag::{Expr, SamplerType, Trace, Type},
1616
primitives::value_arg,
1717
program_def::{ProgramDef, UniformBlockDef, UniformSamplerDef, VertexBlockDef},
1818
sig::{FromFsInput, FromVsInput, VsFunc, VsSig},
@@ -190,6 +190,8 @@ where
190190
source
191191
};
192192

193+
Trace::clear_cache();
194+
193195
ProgramDef {
194196
uniform_block_defs,
195197
uniform_sampler_defs,

0 commit comments

Comments
 (0)