On Fri, Apr 28, 2017 at 12:28 PM, Zellyn <zel...@gmail.com> wrote:
> I'm sure I'm doing something hideously wrong with shiny, since my emulator
> runs three times faster on my MacBook if I run it under VirtualBox/Ubuntu.
> Yes, you read that right.
> Here, I tweeted an animated gif of them running side by side:
> https://twitter.com/zellyn/status/857674501928222720
>
> I ripped out the emulator code and made it simply plot a pixel each frame.
> Here's the result, which still runs much faster under a virtual machine:
> https://play.golang.org/p/par16HK1X2

It's probably unrelated to your different frame rate, but FYI, your
use of the "done" variable from two goroutines is incorrect
synchronization. See https://golang.org/ref/mem#tmp_10


> I'm sure I'm doing the wrong kind of texture update / buffer copy /
> something wrong. Please, educate me! Extra points for explaining enough to
> us all that we could understand what's actually going on.

I suspect that it's because the w.Publish call behavior differs across
the two. I think that, on Mac, IIRC, Publish will block until the
pixels actually hit the screen, so at 60Hz, that might block for up to
16ms. On Linux, Publish will block until the drawing commands hit the
X server, and that X server doesn't tell us when the 60Hz vsync is.

It would indeed be good to make w.Publish behave consistently across
the platforms, but I don't have a good design for that, considering
how little X tells you about vsync. That's AFAICT. I'd love to be
proven wrong about X and vsync.

An alternative approach is to separate your simulation loop and your
rendering loop. The example/fluid program in the shiny code might give
you some inspiration.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to