Sunshine latest
Self-hosted game stream host for Moonlight.
display_base.cpp File Reference

Definitions for the Windows display base code. More...

#include <cmath>
#include <thread>
#include <initguid.h>
#include <boost/algorithm/string/join.hpp>
#include <boost/process/v1.hpp>
#include <MinHook.h>
#include "display.h"
#include "misc.h"
#include "src/config.h"
#include "src/display_device.h"
#include "src/logging.h"
#include "src/platform/common.h"
#include "src/video.h"
Include dependency graph for display_base.cpp:

Typedefs

typedef enum _D3DKMT_GPU_PREFERENCE_QUERY_STATE D3DKMT_GPU_PREFERENCE_QUERY_STATE
 
typedef long NTSTATUS
 

Enumerations

enum  _D3DKMT_GPU_PREFERENCE_QUERY_STATE : DWORD {
  D3DKMT_GPU_PREFERENCE_STATE_UNINITIALIZED , D3DKMT_GPU_PREFERENCE_STATE_HIGH_PERFORMANCE , D3DKMT_GPU_PREFERENCE_STATE_MINIMUM_POWER , D3DKMT_GPU_PREFERENCE_STATE_UNSPECIFIED ,
  D3DKMT_GPU_PREFERENCE_STATE_NOT_FOUND , D3DKMT_GPU_PREFERENCE_STATE_USER_SPECIFIED_GPU
}
 

Functions

std::shared_ptr< display_tplatf::display (mem_type_e hwdevice_type, const std::string &display_name, const video::config_t &config)
 Get the display_t instance for the given hwdevice_type. If display_name is empty, use the first monitor that's compatible you can find If you require to use this parameter in a separate thread, make a copy of it.
 
std::vector< std::string > platf::display_names (mem_type_e hwdevice_type)
 
bool platf::needs_encoder_reenumeration ()
 Check if GPUs/drivers have changed since the last call to this function.
 
NTSTATUS __stdcall platf::dxgi::NtGdiDdDDIGetCachedHybridQueryValueHook (D3DKMT_GPU_PREFERENCE_QUERY_STATE *gpuPreference)
 Hook for NtGdiDdDDIGetCachedHybridQueryValue() from win32u.dll.
 
bool platf::dxgi::test_dxgi_duplication (adapter_t &adapter, output_t &output, bool enumeration_only)
 Tests to determine if the Desktop Duplication API can capture the given output.
 

Detailed Description

Definitions for the Windows display base code.

Enumeration Type Documentation

◆ _D3DKMT_GPU_PREFERENCE_QUERY_STATE

Enumerator
D3DKMT_GPU_PREFERENCE_STATE_UNINITIALIZED 

The GPU preference isn't initialized.

D3DKMT_GPU_PREFERENCE_STATE_HIGH_PERFORMANCE 

The highest performing GPU is preferred.

D3DKMT_GPU_PREFERENCE_STATE_MINIMUM_POWER 

The minimum-powered GPU is preferred.

D3DKMT_GPU_PREFERENCE_STATE_UNSPECIFIED 

A GPU preference isn't specified.

D3DKMT_GPU_PREFERENCE_STATE_NOT_FOUND 

A GPU preference isn't found.

D3DKMT_GPU_PREFERENCE_STATE_USER_SPECIFIED_GPU 

A specific GPU is preferred.

Function Documentation

◆ display()

std::shared_ptr< display_t > platf::display ( platf::mem_type_e hwdevice_type,
const std::string & display_name,
const video::config_t & config )

Get the display_t instance for the given hwdevice_type. If display_name is empty, use the first monitor that's compatible you can find If you require to use this parameter in a separate thread, make a copy of it.

Parameters
display_nameThe name of the monitor that SHOULD be displayed
configStream configuration
Returns
The display_t instance based on hwdevice_type.

Pick a display adapter and capture method.

Parameters
hwdevice_typeenables possible use of hardware encoder

◆ needs_encoder_reenumeration()

bool platf::needs_encoder_reenumeration ( )

Check if GPUs/drivers have changed since the last call to this function.

Returns if GPUs/drivers have changed since the last call to this function.

Returns
true if a change has occurred or if it is unknown whether a change occurred.

◆ NtGdiDdDDIGetCachedHybridQueryValueHook()

NTSTATUS __stdcall platf::dxgi::NtGdiDdDDIGetCachedHybridQueryValueHook ( D3DKMT_GPU_PREFERENCE_QUERY_STATE * gpuPreference)

Hook for NtGdiDdDDIGetCachedHybridQueryValue() from win32u.dll.

Parameters
gpuPreferenceA pointer to the location where the preference will be written.
Returns
Always STATUS_SUCCESS if valid arguments are provided.

◆ test_dxgi_duplication()

bool platf::dxgi::test_dxgi_duplication ( adapter_t & adapter,
output_t & output,
bool enumeration_only )

Tests to determine if the Desktop Duplication API can capture the given output.

When testing for enumeration only, we avoid resyncing the thread desktop.

Parameters
adapterThe DXGI adapter to use for capture.
outputThe DXGI output to capture.
enumeration_onlySpecifies whether this test is occurring for display enumeration.