ruffle icon indicating copy to clipboard operation
ruffle copied to clipboard

avm2: Implement `BitmapData.draw` for `wgpu` backend

Open Aaron1011 opened this issue 3 years ago • 0 comments

This method requires us to have the ability to render directly to a texture. Fortunately, the wgpu backend already supports this in the form of TextureTarget. However, the rendering code required some refactoring in order to avoid creating duplicate wgpu resources.

The current implementation blocks on copying the pixels back from the GPU to the CPU, so that we can immediately set them in the Ruffle BitmapData. This is likely very inefficient, but will work for a first implementation.

In the future, we could explore allowing the CPU image data and GPU texture to be out of sync, and only synchronized when explicitly necessary (e.g. on getPixel or setPixel calls).

Aaron1011 avatar Jun 18 '22 18:06 Aaron1011