New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/exp/shiny: assigning to *buf.RGBA() works on gldriver but not x11driver #14191
Comments
The short answer is, no, it should not work. A Buffer is essentially an *image.RGBA, but not all *image.RGBAs are valid Buffers. (If they were, the Upload method might as well take an *image.RGBA instead of a Buffer). Drivers may assume that the memory backing a Buffer's pixels are specially allocated, such as shared memory, shared across multiple processes. Arbitrary *image.RGBAs do not satisfy that assumption. As I tried to say on #14026, your Editor shouldn't have an *image.RGBA or be an *image.RGBA. Instead, it should be able to render itself onto a Buffer's *image.RGBA (where the Buffer is provided by Screen.NewBuffer). On a side note, with your original code snippet: *buf.RGBA() = *img you might not need to explicitly use a Texture. A Window already has an Upload method, which takes a Buffer. |
Ah, thank you. This is obvious now that you say it (I missed it last time, apparently). I've been stuck on the idea that I need to construct my own image, and then copy it to the buffer.
Yes, my example code was simplified. Usually I can reuse the texture (which I believe is hypothetically cheaper than uploading the buffer each time). |
CL https://golang.org/cl/19211 mentions this issue. |
A Buffer is essentially an *image.RGBA, but not all *image.RGBAs are valid Buffers. This change detects invalid attempts to pass arbitrary *image.RGBAs as Buffers. Prior to this change, this would 'work' for the gldriver but not other drivers. Fixes golang/go#14191. Change-Id: I8b0d7f0861dc69b93d332bd0ba26a70326e16c7b Reviewed-on: https://go-review.googlesource.com/19211 Reviewed-by: David Crawshaw <crawshaw@golang.org>
I had some code like this:
This worked on gldriver, but not x11driver. After switching to the following, it worked on both:
I have not yet investigated why it works on one but not the other, but first: should this work? It feels like I'm paying a performance penalty by drawing my image to buf.RGBA() when I already have exactly the image that I want.
The text was updated successfully, but these errors were encountered: