Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ CComposition::EndProcessVideo()
//-----------------------------------------------------------------------------

HRESULT CComposition::ProcessComposition(
bool canRenderWithoutDisplayDevices,
__out_ecount(1) bool *pfPresentNeeded
)
{
Expand Down Expand Up @@ -643,7 +644,7 @@ HRESULT CComposition::ProcessComposition(
//
auto& compatSettings = g_pPartitionManager->GetCompatSettings();

doRenderPass = compatSettings.ShouldRenderEvenWhenNoDisplayDevicesAreAvailable();
doRenderPass = canRenderWithoutDisplayDevices || compatSettings.ShouldRenderEvenWhenNoDisplayDevicesAreAvailable();
//
// Make sure that we invalidate all of the render targets and caches,
// and notify any listeners that display set is not valid
Expand Down Expand Up @@ -773,6 +774,7 @@ HRESULT CComposition::ProcessComposition(
//------------------------------------------------------------------------------
HRESULT
CComposition::Compose(
bool canRenderWithoutDisplayDevices,
__out_ecount(1) bool *pfPresentNeeded
)
{
Expand Down Expand Up @@ -802,7 +804,7 @@ CComposition::Compose(
// If not zombie, perform the render and optional present passes...
//

IFC(ProcessComposition(&fPresentNeeded));
IFC(ProcessComposition(canRenderWithoutDisplayDevices, &fPresentNeeded));
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.DotNet.Wpf/src/WpfGfx/core/uce/composition.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class CComposition :
// Runs any necessary updates to the composition - all the resources
// participating in the composition, the thread, or device management.
override HRESULT Compose(
bool canRenderWithoutDisplayDevices,
__out_ecount(1) bool *pfPresentNeeded
);

Expand Down Expand Up @@ -285,6 +286,7 @@ class CComposition :
// Performs the compositor duties by processing any pending batches,
// updating the video subsystem, rendering and ticking animations.
HRESULT ProcessComposition(
bool canRenderWithoutDisplayDevices,
__out_ecount(1) bool *pfPresentNeeded
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,14 @@ CConnectionContext::PresentAllPartitions()
{
bool fPresentNeeded = false;

MIL_THR(pServerEntry->pCompDevice->Compose(&fPresentNeeded));
// So far this method is used only to synchronously present on managed UI
// thread when calling RenderTargetBitmap.Render or alike. This can happen
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar nit in the new comment: "RenderTargetBitmap.Render or alike" is awkward/incorrect English. Consider changing to "RenderTargetBitmap.Render or similar" (or "and similar APIs").

Suggested change
// thread when calling RenderTargetBitmap.Render or alike. This can happen
// thread when calling RenderTargetBitmap.Render or similar APIs. This can happen

Copilot uses AI. Check for mistakes.
// when an app is running without any monitors, e.g. when Visual Studio
// restarts on a DevBox machine overnight after update. In this case we want
// to allow rendering without any displays. Otherwise RenderTargetBitmap images
// will appear blank when user reconnects to DevBox the next day.
MIL_THR(pServerEntry->pCompDevice->Compose(
/*canRenderWithoutDisplayDevices*/true, &fPresentNeeded));

if (hr != WGXERR_DISPLAYSTATEINVALID)
{
Expand Down
1 change: 1 addition & 0 deletions src/Microsoft.DotNet.Wpf/src/WpfGfx/core/uce/partition.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class __declspec(novtable) Partition :
virtual ~Partition() {}

virtual HRESULT Compose(
bool canRenderWithoutDisplayDevices,
__out_ecount(1) bool *pfNeedsPresent
) = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,14 @@ CPartitionThread::RenderPartition(
{
HRESULT hr = S_OK;
bool presentThisPartition = false;
MIL_THR(pPartition->Compose(&presentThisPartition));

// This code path is for regular WPF rendering. By default we do not allow
// rendering without display devices being present. App authors can still
// allow that with following switch in their app config file:
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar nit in the new comment: "allow that with following switch" reads like a typo. Consider "allow that with the following switch" for clarity.

Suggested change
// allow that with following switch in their app config file:
// allow that with the following switch in their app config file:

Copilot uses AI. Check for mistakes.
// <AppContextSwitchOverrides value="Switch.System.Windows.Media.ShouldRenderEvenWhenNoDisplayDevicesAreAvailable=true" />
MIL_THR(pPartition->Compose(
/*canRenderWithoutDisplayDevices*/false, &presentThisPartition));

if (FAILED(hr))
{
//
Expand Down