1

I'm new to Imgui and Vulkan and I'm trying to display an image captured from a webcam using OpenCV. Imgui documentation states that I should:

Load the raw decompressed RGBA image from RAM into a GPU texture. You'll want to use dedicated functions of your graphics API (e.g. OpenGL, DirectX11) to do this.

But their is no example of that using Vulkan API.

davdsb
  • 101
  • 1
  • 10
  • You want to know how to make an array of pixels into a texture? – user253751 May 19 '22 at 15:28
  • In Vulkan, yes. And get this texture's ID – davdsb May 19 '22 at 15:37
  • 1
    sounds like a basic Vulkan thing. I don't know Vulkan at all, but I'd start by reading a Vulkan tutorial – user253751 May 19 '22 at 15:46
  • Stream your RGBA pixels into a host-visible buffer and use vkCmdCopyBufferToImage to transfer those pixels to an optimal-tiling VkImage. Yes, you need to get all the synchronization (CPU->GPU, GPU->GPU) right. – James0124 May 24 '22 at 06:44
  • @James0124 Do you have any documentation explaining the process? – davdsb May 24 '22 at 09:33
  • 2
    @davdsb I don't know of any specific documentation, but [this questions's code](https://stackoverflow.com/questions/61208293/is-there-a-way-update-a-texture-with-out-using-a-staging-buffer) might give you an overview. It creates/destroys a staging buffer every frame and over-synchronizes, but it's a start. You might find yourself reading the relevant parts of the Vulkan spec over and over again if you're new to Vulkan and dynamic texture upload is what you want to do. And _then_ on top of that you need to think about sampling it in your ImGui fragment shader. – James0124 May 24 '22 at 17:44
  • 1
    @davdsb And you might want to start with a static texture first, if you haven't already. Dynamic texture uploading _and_ sampling from it has many pitfalls, especially if you're a beginner in Vulkan. – James0124 May 24 '22 at 17:49

0 Answers0