simple stat
This commit is contained in:
+26
-2
@@ -462,7 +462,7 @@ func main() {
|
|||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
grant := make(chan struct{})
|
grant := make(chan struct{})
|
||||||
staged := make(chan struct{})
|
staged := make(chan uint64)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
@@ -485,7 +485,7 @@ func main() {
|
|||||||
vk.CopyToMapped(staging.Mapped, f.Payload)
|
vk.CopyToMapped(staging.Mapped, f.Payload)
|
||||||
// fmt.Println("staged", f.Index)
|
// fmt.Println("staged", f.Index)
|
||||||
select {
|
select {
|
||||||
case staged <- struct{}{}:
|
case staged <- f.Index:
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -500,7 +500,14 @@ func main() {
|
|||||||
running := true
|
running := true
|
||||||
resized := false
|
resized := false
|
||||||
fullscreen := false
|
fullscreen := false
|
||||||
|
var (
|
||||||
|
lastIndex uint64
|
||||||
|
dropped uint64
|
||||||
|
frameCount uint64
|
||||||
|
lastReport time.Time
|
||||||
|
)
|
||||||
for running {
|
for running {
|
||||||
|
frameStart := time.Now()
|
||||||
var event [128]byte
|
var event [128]byte
|
||||||
for sdlPollEvent(unsafe.Pointer(&event[0])) {
|
for sdlPollEvent(unsafe.Pointer(&event[0])) {
|
||||||
eventType := *(*uint32)(unsafe.Pointer(&event[0]))
|
eventType := *(*uint32)(unsafe.Pointer(&event[0]))
|
||||||
@@ -558,12 +565,29 @@ func main() {
|
|||||||
running = false
|
running = false
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
var shownIndex uint64
|
||||||
select {
|
select {
|
||||||
case <-staged:
|
case <-staged:
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
running = false
|
running = false
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if lastIndex != 0 && shownIndex > lastIndex {
|
||||||
|
if g := shownIndex - lastIndex - 1; g > 0 {
|
||||||
|
dropped += g
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lastIndex = shownIndex
|
||||||
|
frameCount++
|
||||||
|
if now := time.Now(); now.Sub(lastReport) >= time.Second {
|
||||||
|
dt := now.Sub(lastReport).Seconds()
|
||||||
|
fps := float64(frameCount) / dt
|
||||||
|
fmt.Printf("fps=%.1f dropped=%d idx=%d frameTime=%.2fms\n",
|
||||||
|
fps, dropped, shownIndex, float64(now.Sub(frameStart).Microseconds())/1000.0)
|
||||||
|
frameCount = 0
|
||||||
|
dropped = 0
|
||||||
|
lastReport = now
|
||||||
|
}
|
||||||
|
|
||||||
// Record: copy staged V210 into device-local buffer, then clear
|
// Record: copy staged V210 into device-local buffer, then clear
|
||||||
cmd := vkCommands[0]
|
cmd := vkCommands[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user