Sunshine0.0.5917
Sunshine 0.0.5917
Self-hosted game stream host for Moonlight.
Loading...
Searching...
No Matches
platf::dxgi::display_vram_t Class Reference

#include <src/platform/windows/display.h>

Inheritance diagram for platf::dxgi::display_vram_t:
Collaboration diagram for platf::dxgi::display_vram_t:

Public Member Functions

std::shared_ptr< img_t > alloc_img () override
 Allocate an image buffer compatible with this display backend.
int complete_img (img_t *img_base, bool dummy) override
 Finalize a VRAM image after capture or dummy-frame generation.
int dummy_img (img_t *img_base) override
 Populate a fallback image when real capture data is unavailable.
int dummy_img (platf::img_t *img_base)
 Populate a fallback image when real capture data is unavailable.
std::vector< DXGI_FORMAT > get_supported_capture_formats () override
 Get supported capture formats.
bool is_codec_supported (std::string_view name, const ::video::config_t &config) override
 Check that a given codec is supported by the display device.
std::unique_ptr< avcodec_encode_device_t > make_avcodec_encode_device (pix_fmt_e pix_fmt) override
 Create AVCodec encode device.
std::unique_ptr< nvenc_encode_device_t > make_nvenc_encode_device (pix_fmt_e pix_fmt) override
 Create NVENC encode device.
Public Member Functions inherited from platf::dxgi::display_base_t
capture_e capture (const push_captured_image_cb_t &push_captured_image_cb, const pull_free_image_cb_t &pull_free_image_cb, bool *cursor) override
 Capture a frame.
const char * colorspace_to_string (DXGI_COLOR_SPACE_TYPE type)
 Convert a DXGI colorspace enum to a diagnostic string.
const char * dxgi_format_to_string (DXGI_FORMAT format)
 Convert a DXGI format enum to a diagnostic string.
bool get_hdr_metadata (SS_HDR_METADATA &metadata) override
 Read HDR metadata for the active display mode.
int init (const ::video::config_t &config, const std::string &display_name)
 Initialize D3D11 desktop duplication for the selected output.
bool is_hdr () override
 Report whether the active display mode is HDR.

Public Attributes

std::atomic< uint32_t > next_image_id
 Next image ID.
Public Attributes inherited from platf::dxgi::display_base_t
adapter_t adapter
 DXGI adapter containing the selected output.
DXGI_FORMAT capture_format
 Capture format.
int client_frame_rate
 Client frame rate.
DXGI_RATIONAL client_frame_rate_strict
 Client frame rate strict.
device_t device
 D3D11 device used for desktop duplication capture.
device_ctx_t device_ctx
 D3D11 device context used for copy and render operations.
DXGI_RATIONAL display_refresh_rate
 Display refresh rate.
int display_refresh_rate_rounded
 Display refresh rate rounded.
DXGI_MODE_ROTATION display_rotation = DXGI_MODE_ROTATION_UNSPECIFIED
 Display rotation.
factory1_t factory
 DXGI factory used to enumerate adapters and outputs.
D3D_FEATURE_LEVEL feature_level
 Feature level.
int height_before_rotation
 Height before rotation.
const UINT KMTQAITYPE_WDDM_2_7_CAPS = 70
 Protocol or platform constant for kmtqaitype wddm 2 7 caps.
output_t output
 DXGI output duplicated for capture.
std::unique_ptr< high_precision_timer > timer = create_high_precision_timer()
 Timer.
int width_before_rotation
 Width before rotation.
Public Attributes inherited from platf::display_t
int env_height {0}
 Height of the full capture environment in physical pixels.
int env_logical_height {0}
 Height of the full capture environment after display scaling.
int env_logical_width {0}
 Width of the full capture environment after display scaling.
int env_offset_x {0}
 Horizontal origin of the full capture environment in native desktop coordinates.
int env_offset_y {0}
 Vertical origin of the full capture environment in native desktop coordinates.
int env_width {0}
 Width of the full capture environment in physical pixels.
int height {0}
 Height of the captured display in physical pixels.
int logical_height {0}
 Height of the captured display after display scaling.
int logical_width {0}
 Width of the captured display after display scaling.
int offset_x {0}
 Horizontal capture offset in physical pixels.
int offset_y {0}
 Vertical capture offset in physical pixels.
int width {0}
 Width of the captured display in physical pixels.

Additional Inherited Members

Public Types inherited from platf::dxgi::display_base_t
enum  _D3DKMT_SCHEDULINGPRIORITYCLASS {
  D3DKMT_SCHEDULINGPRIORITYCLASS_IDLE , D3DKMT_SCHEDULINGPRIORITYCLASS_BELOW_NORMAL , D3DKMT_SCHEDULINGPRIORITYCLASS_NORMAL , D3DKMT_SCHEDULINGPRIORITYCLASS_ABOVE_NORMAL ,
  D3DKMT_SCHEDULINGPRIORITYCLASS_HIGH , D3DKMT_SCHEDULINGPRIORITYCLASS_REALTIME
}
 Enumerates supported d3 DKMT SCHEDULINGPRIORITYCLASS options. More...
using D3DKMT_CLOSEADAPTER = _D3DKMT_CLOSEADAPTER
 Adapter-close request passed to D3DKMT.
using D3DKMT_HANDLE = UINT
 Kernel-mode D3DKMT adapter handle.
using D3DKMT_OPENADAPTERFROMLUID = _D3DKMT_OPENADAPTERFROMLUID
 Adapter-open request passed to D3DKMT.
using D3DKMT_QUERYADAPTERINFO = _D3DKMT_QUERYADAPTERINFO
 Adapter-information query passed to D3DKMT.
using D3DKMT_SCHEDULINGPRIORITYCLASS = _D3DKMT_SCHEDULINGPRIORITYCLASS
 Process scheduling priority class passed to D3DKMT.
using D3DKMT_WDDM_2_7_CAPS = _D3DKMT_WDDM_2_7_CAPS
 WDDM 2.7 capability flags returned by D3DKMT.
using PD3DKMTCloseAdapter = NTSTATUS(WINAPI *)(D3DKMT_CLOSEADAPTER *)
 Function pointer for closing a D3DKMT adapter handle.
using PD3DKMTOpenAdapterFromLuid = NTSTATUS(WINAPI *)(D3DKMT_OPENADAPTERFROMLUID *)
 Function pointer for opening a D3DKMT adapter by LUID.
using PD3DKMTQueryAdapterInfo = NTSTATUS(WINAPI *)(D3DKMT_QUERYADAPTERINFO *)
 Function pointer for querying D3DKMT adapter information.
using PD3DKMTSetProcessSchedulingPriorityClass = NTSTATUS(WINAPI *)(HANDLE, D3DKMT_SCHEDULINGPRIORITYCLASS)
 Function pointer for setting D3DKMT process scheduling priority.
Public Types inherited from platf::display_t
using pull_free_image_cb_t = std::function<bool(std::shared_ptr<img_t> &img_out)>
 Get free image from pool. Calls must be synchronized. Blocks until there is free image in the pool or capture is interrupted.
using push_captured_image_cb_t = std::function<bool(std::shared_ptr<img_t> &&img, bool frame_captured)>
 Callback for when a new image is ready. When display has a new image ready or a timeout occurs, this callback will be called with the image. If a frame was captured, frame_captured will be true. If a timeout occurred, it will be false.
Protected Member Functions inherited from platf::dxgi::display_base_t
int get_pixel_pitch () const
 Get pixel pitch.
virtual capture_e release_snapshot ()=0
 Release resources associated with the last captured snapshot.
virtual capture_e snapshot (const pull_free_image_cb_t &pull_free_image_cb, std::shared_ptr< platf::img_t > &img_out, std::chrono::milliseconds timeout, bool cursor_visible)=0
 Capture a display frame into the provided image object.
Protected Attributes inherited from platf::display_t
logging::time_delta_periodic_logger sleep_overshoot_logger = {debug, "Frame capture sleep overshoot"}
 Periodic logger for capture sleep overshoot measurements.

Detailed Description

Display component for devices that use hardware encoders.

Member Function Documentation

◆ alloc_img()

std::shared_ptr< platf::img_t > platf::dxgi::display_vram_t::alloc_img ( )
overridevirtual

Allocate an image buffer compatible with this display backend.

Returns
Allocated img object, or null when unavailable.

Implements platf::display_t.

◆ complete_img()

int platf::dxgi::display_vram_t::complete_img ( img_t * img_base,
bool dummy )
overridevirtual

Finalize a VRAM image after capture or dummy-frame generation.

Parameters
img_baseImage buffer whose D3D resources are finalized.
dummyUnused placeholder required by the interface signature.
Returns
Capture status after finalizing the captured image.

Implements platf::dxgi::display_base_t.

◆ dummy_img() [1/2]

int platf::dxgi::display_vram_t::dummy_img ( img_t * img_base)
override

Populate a fallback image when real capture data is unavailable.

Parameters
img_baseImage buffer populated with a fallback frame.
Returns
Capture status reported to the streaming pipeline.

◆ dummy_img() [2/2]

int dummy_img ( platf::img_t * img)
virtual

Populate a fallback image when real capture data is unavailable.

Parameters
imgImage or frame object to read from or populate.
Returns
Capture status reported to the streaming pipeline.

Implements platf::display_t.

◆ get_supported_capture_formats()

std::vector< DXGI_FORMAT > platf::dxgi::display_vram_t::get_supported_capture_formats ( )
overridevirtual

Get supported capture formats.

Returns
Capture formats supported by this display backend.

Implements platf::dxgi::display_base_t.

◆ is_codec_supported()

bool platf::dxgi::display_vram_t::is_codec_supported ( std::string_view name,
const ::video::config_t & config )
overridevirtual

Check that a given codec is supported by the display device.

Parameters
nameThe FFmpeg codec name (or similar for non-FFmpeg codecs).
configThe codec configuration.
Returns
true if supported, false otherwise.

Reimplemented from platf::display_t.

◆ make_avcodec_encode_device()

std::unique_ptr< avcodec_encode_device_t > platf::dxgi::display_vram_t::make_avcodec_encode_device ( pix_fmt_e pix_fmt)
overridevirtual

Create AVCodec encode device.

Parameters
pix_fmtSunshine pixel format to convert or allocate for.
Returns
Constructed AVCodec encode device object.

Reimplemented from platf::display_t.

◆ make_nvenc_encode_device()

std::unique_ptr< nvenc_encode_device_t > platf::dxgi::display_vram_t::make_nvenc_encode_device ( pix_fmt_e pix_fmt)
overridevirtual

Create NVENC encode device.

Parameters
pix_fmtSunshine pixel format to convert or allocate for.
Returns
Constructed NVENC encode device object.

Reimplemented from platf::display_t.


The documentation for this class was generated from the following files: