Enhancement of RenderTargetBitmap to Support Hardware Rendering #9024
+273
−17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 asShaderEffect
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 aRenderTargetBitmap
.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