github.com/racerxdl/gonx@v0.0.0-20210103083128-c5afc43bcbd2/services/display/fence.go (about) 1 package display 2 3 import ( 4 "github.com/racerxdl/gonx/nx/nxerrors" 5 "github.com/racerxdl/gonx/services/gpu" 6 "github.com/racerxdl/gonx/services/vi" 7 "unsafe" 8 ) 9 10 type Fence struct { 11 IsValid uint32 12 Sync [4]gpu.Fence 13 } 14 15 func UnflattenFence(p *vi.Parcel) (fence Fence, err error) { 16 size := p.ReadU32() 17 numFds := p.ReadU32() 18 19 if uintptr(size) != unsafe.Sizeof(fence) { 20 return fence, nxerrors.DisplayInvalidFence 21 } 22 23 if numFds != 0 { 24 return fence, nxerrors.DisplayFenceTooManyFds 25 } 26 27 fence.IsValid = p.ReadU32() 28 29 for i := range fence.Sync { 30 fence.Sync[i].SyncptId = 0xFFFFFFFF // Fill with default values 31 } 32 33 for i := 0; i < len(fence.Sync) && p.Remaining() > 8; i++ { 34 fence.Sync[i].SyncptId = p.ReadU32() 35 fence.Sync[i].SyncptValue = p.ReadU32() 36 } 37 38 return fence, nil 39 }