dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
6.84k stars 1.13k forks source link

Enhancement of RenderTargetBitmap to Support Hardware Rendering #9024

Open DearVa opened 1 month ago

DearVa commented 1 month ago

Fixes #9021

Description

In WPF, RenderTargetBitmap (also RTB) currently only supports software rendering. This limitation leads to performance bottlenecks and causes ShaderEffect implementations to become ineffective. Enhancing RTB to support hardware rendering would provide significant performance improvements and enable high-quality rendering features that are currently restricted. This limitation has been extensively discussed in the past (#144, Add optional hardware acceleration to RenderTargetBitmap and some website was lost: RenderTargetBitmap and Hardware WPF Rendering).

As a developer who is proficient in graphics and C#, one of my requirements is to export WPF-rendered UI as video efficiently. Current methods such as using BitmapCache (which cannot retrieve content back to memory) and hooking DirectX APIs (which is complex and unstable) are not feasible solutions.

Customer Impact

RenderTargetBitmap will only support software rendering and may experience performance bottlenecks as well as ShaderEffect not working as expected.

Regression

No

Testing

Additional tests may need to be added to verify that it behaves correctly with different drivers (no graphics, integrated graphics, discrete graphics) and in the event of missing devices, etc. May also need to check for potential memory leaks.

Risk

Due to API changes, PixelFormats.Prgba128Float will no longer be supported when creating a RenderTargetBitmap.

Although code can fall back to software when no hardware device context is acquired, this needs to be extensively verified. May also need to check for potential memory leaks.

This is a huge change, but I think it deserves to be discussed in depth and considered carefully!

Microsoft Reviewers: Open in CodeFlow
DearVa commented 1 month ago

@dotnet-policy-service agree

lindexi commented 1 month ago

Awesome! 666

RCUTANF commented 1 month ago

incredible performance improve! I will test in my device later.

DearVa commented 1 week ago

Hello every reviewers, I was wondering if there's any update on this PR? @singhashish-wpf @dipeshmsft I tagged you as you seem to be the expert in this area and I'm a bit lost on how to proceed. My apologies if I'm out of line.

hez2010 commented 4 days ago

Hello every reviewers, I was wondering if there's any update on this PR? @singhashish-wpf @dipeshmsft I tagged you as you seem to be the expert in this area and I'm a bit lost on how to proceed. My apologies if I'm out of line.

Pretty sure this PR will be on hold for yet another several months before it finally gets reviewed and merged just like any other community PR which touches some fundamental things.

DearVa commented 4 days ago

Hello every reviewers, I was wondering if there's any update on this PR? @singhashish-wpf @dipeshmsft I tagged you as you seem to be the expert in this area and I'm a bit lost on how to proceed. My apologies if I'm out of line.

Pretty sure this PR will be on hold for yet another several months before it finally gets reviewed and merged just like any other community PR which touches some fundamental things.

Thanks for your reply, waiting for good news!