-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Avoiding unnecessary buffer copies #107
Comments
How often are you submitting a new texture to the GPU? You should try to reduce this as much as possible. If you are producing individual pixels in your update logic, Coffee is probably not a good fit for your use case. Coffee allows you to load and draw sprites, quads, meshes, and UI widgets easily by leveraging the GPU. It is not optimized for drawing individual pixels. For something like that, you will probably have a better time with something like If you are only loading resources every once in a while, I do not think an additional copy will matter unless you are dealing with a lot of images. We should probably perform some benchmarks (see #13) and profile it before optimizing anything, specially when there is not a clear way to go about it. |
I don't know yet!
Fair enough. |
The coffee/src/graphics/backend_wgpu/texture.rs Line 259 in e1bb429
When I wrote this, I was just starting with Rust and I didn't focus much on performance, given that it's a method that should be used rarely, so there is definitely room for improvement/micro-optimization (see #7). |
Lol, I did test on the opengl backend, not vulkan |
About pub fn from_image(gpu: &mut Gpu, image: &image::RgbaImage) -> Result<Image> Is probably a cleaner API: anyone that already have an |
I submitted #104 to avoid copying the buffer every time I submit a texture to the gpu, but it turns out that each gpu backend receives a
&image::DynamicImage
and performs another copy anyway. (well one copy is better than two, but still)on the gfx backend it always performs a copy (even if the image already is rgba)
on the wpu backend it always performs a copy too, even if it's already gbra (also: why do the two backends use a different color order for textures?)
For the opengl backend: I can't find it.
Well it's unavoidable to perform copies if the image isn't the right format, but it can be avoided if it is. But copying on some backends and not on others doesn't sound good, so I'm not sure if there's something that can be done.
(Anyway, my point of view is: the more optimized coffee is, the more people can get away with poorly optimized game code.)
The text was updated successfully, but these errors were encountered: