Skip to content
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

How to get YUV images from swapchain? #152

Open
zhuowp opened this issue Sep 3, 2024 · 7 comments
Open

How to get YUV images from swapchain? #152

zhuowp opened this issue Sep 3, 2024 · 7 comments
Labels
question Further information is requested

Comments

@zhuowp
Copy link

zhuowp commented Sep 3, 2024

I originally got the RGBA data from Swapchain, but it took a long time to Copy and Map it on my CPU. Therefore, I want to try to take YUV data directly from Swapchain to see if the Copy time can be reduced by reducing the size of image data.

In the functions:
IddSampleEvtIddCxAdapterQueryTargetInfo
IddSampleEvtIddCxParseMonitorDescription2
IddSampleEvtIddCxMonitorQueryTargetModes2
I sets YCbCr422 = IDDCX_BITS_PER_COMPONENT_8 and Rgb = IDDCX_BITS_PER_COMPONENT_NONE to make the color format of the virtual display YCbCr422, which does work. The color format of the virtual display did change to YCbCr422 in Windows setting, but the data I got from SwapChain was still in RGBA format.

What can I do to get YUV data directly from SwapChain

@zhuowp
Copy link
Author

zhuowp commented Sep 3, 2024

screenshot-20240903-162912

@bud3699
Copy link
Collaborator

bud3699 commented Sep 4, 2024

In that case you may need to modify and build the driver with a modified swap chain buffer to one which supports outputting the correct format, making sure the swap chain is properly formatted, at least that's my best guess as of right now.

May I enquire to why you want to do this ?

@zhuowp
Copy link
Author

zhuowp commented Sep 5, 2024

@bud3699 Thanks for your reply.
The key problem is that I do not know how to modify the swap chain to support yuv format. Do you have some idea to help me?

For you question, I'm trying to use virtio gpu driver from intel to display Windows image in qemu.(see
https://github.com/intel/Display-Virtualization-for-Windows-OS ). But it took a long time to Copy and Map desktop images from swap chain to memory with intel-1235u cpu. Therefore, I want to try to take YUV data directly from Swapchain to see if the Copy time can be reduced by reducing the size of image data.

@bud3699
Copy link
Collaborator

bud3699 commented Sep 5, 2024

@zhuowp

I guess lets break it down

  1. we need to make sure the Buffer is in the correct format for the swap chain
  2. check if the Direct3D Device supports the format, maybe fall back if it doesn't just to be on safe side
  3. If you want to do frame handling in the code then do so, process the YUV data
  4. Set the colour encoding

Again, this is only theory, I'm still setting up my computer after a clean install of windows so I can't test as of now. I'm sorry if this didn't help

@zhuowp
Copy link
Author

zhuowp commented Sep 6, 2024

@bud3699 Thanks a lot.
I'll try that.

@bud3699
Copy link
Collaborator

bud3699 commented Oct 9, 2024

Did it work ????

@bud3699 bud3699 added the question Further information is requested label Oct 9, 2024
@zhuowp
Copy link
Author

zhuowp commented Oct 10, 2024

Did it work ????

Sorry for the late response.But I didn't figure out this.
I Cannot find the API to specify the color format to YUV in swap chain directly.

When I read the Microsoft document about the function"IddCxSwapChainReleaseAndAcquireBuffer2", I found the remarks :
The color space of the surface passed in the [IDDCX_METADATA2](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/iddcx/ns-iddcx-iddcx_metadata2) struct is also passed to the driver. This is because it may change on a per frame basis and not match the color space specified when a mode was committed.

So I'm not sure is there anything I can do to achive that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants