Skip to content

Commit

Permalink
random state updating again
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoreilly committed Jan 9, 2025
1 parent 8937e89 commit 07780e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions axon/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"cogentcore.org/core/enums"
"cogentcore.org/lab/gosl/slbool"
"cogentcore.org/lab/gosl/slrand"
"cogentcore.org/lab/gosl/sltype"
)

//gosl:start
Expand Down Expand Up @@ -116,15 +117,18 @@ func (ctx *Context) DataIndex(idx uint32) uint32 {
return idx % ctx.NData
}

// CycleInc increments at the cycle level
// CycleInc increments at the cycle level. This is the one time when
// Context is used on GPU in read-write mode, vs. read-only.
//
//gosl:pointer-receiver
func (ctx *Context) CycleInc() {
ctx.PhaseCycle++
ctx.Cycle++
ctx.CyclesTotal++
ctx.Time += ctx.TimePerCycle
// ctx.RandCounter.Add(uint32(RandFunIndexN))
// ctx.RandCounter.Add(uint32(RandFunIndexN)):
ctx.RandCounter.Counter = sltype.Uint64Add32(ctx.RandCounter.Counter, uint32(RandFunIndexN))
// note: cannot call writing methods on sub-fields, so have to do it manually.
}

// SlowInc increments the Slow counter and returns true if time
Expand Down
1 change: 1 addition & 0 deletions axon/shaders/CycleInc.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ fn Context_CycleInc(ctx: ptr<function,Context>) {
(*ctx).Cycle++;
(*ctx).CyclesTotal++;
(*ctx).Time += (*ctx).TimePerCycle;
(*ctx).RandCounter.Counter = Uint64Add32((*ctx).RandCounter.Counter, u32(RandFunIndexN));
}

//////// import: "deep-layer.go"
Expand Down

0 comments on commit 07780e6

Please sign in to comment.