1

I'm currently using a custom SurfaceView (MySurfaceView) for my Vulkan application (game), but have read that TextureView is a better choice. I tried changing to a custom TextureView (MyTextureView), but am not getting Resize() or Redraw() events.

I can have the C++ code render on its own thread, I guess, but then how does it notify Java to refresh the TextureView?

Bungles
  • 1,969
  • 2
  • 25
  • 54
  • It's unclear to me where Vulkan is in this picture. Are you using Vulkan to draw into the Surface you obtained from the SurfaceView? And you're rather have a TextureView, get a Surface from that, and render into that using Vulkan? Regardless, though, generally SurfaceView is a better choice; use TextureView *only* if it has features that you really need that SurfaceView can't provide. – Jesse Hall Jan 28 '21 at 04:42
  • My understanding is TextureView is designed for things like video playback where C++ code is constantly updating a texture on another thread. Also TextureView guarantees a hardware surface. I'm currently using C++ Vulkan to render to the Surface I get from a custom SurfaceView. I thought it would work pretty easily to get the surface from TextureView instead, but the TextureView never draws so my C++ code never draws. – Bungles Jan 28 '21 at 06:51
  • Not really. In your main Activity window, a SurfaceView draws a transparent rectangle, and creates another window behind it which the "producer" draws into. The system compositor combines both windows when updating the screen; images from the producer go straight to the compositor. With TextureView, there's just one window. When the view is dirtied and redrawn, it copies the most recent image from the producer into the Activity's window (possibly applying transforms/filters), which then goes to the compositor. So there's extra latency and bandwidth involved in TextureView. – Jesse Hall Jan 29 '21 at 14:56
  • Interesting, thank you. I'd have thought the two-window approach would be slower because the window on top is all transparent. – Bungles Jan 29 '21 at 19:54

0 Answers0