-2

I wrote a simple Vulkan demo with BGRA images queried from swapchain. If I output RGBA pixels to it, the R channel and G channel in final result were swapped.

But when I checked the demo in Vulkan SDK dir, I found that it also use a BGRA image view for color output (I checked this in code and RenderDoc), but the final result is correct!

So, when did the conversion happen? Did I miss something?

vulkan demo output

vulkan demo output

Vulkan demo has a BGRA format output

vulkan demo has a BGRA format output

My poor result

my poor result

Edit:

Sorry about the lack of the code. The first answer gave me a hint to find the real problem in loading image from disk by FreeImage. Images it loads are stored as BGRA format with default setting on windows:

enter image description here

Thanks for your help and advice, @opa and @solidpixel.

hamwj1991
  • 51
  • 8
  • 2
    With out code, we cannot help you, your question may eventually get closed and flagged if changes are not made to your question. – Krupip Dec 17 '18 at 16:05

1 Answers1

1

You're either setting up your texture reads incorrectly, or you're setting up your swapchain writes incorrectly. If I had to guess you're uploading data into the wrong texture format, but without a complete example it's hard to tell.

solidpixel
  • 10,688
  • 1
  • 20
  • 33
  • 3
    As it stands, this would work much better as a comment than an answer, answers should be useful in their own right, and this one just isn't. – Krupip Dec 17 '18 at 16:05
  • Well, given the OP mentioned that the swapchain was the same setup as an example that worked the probability is that the texture reads are the problem. Still, will post as a comment next time ... – solidpixel Dec 18 '18 at 08:34