Sunshine0.0.5917
Sunshine 0.0.5917
Self-hosted game stream host for Moonlight.
Loading...
Searching...
No Matches
Go to the documentation of this file.
1
5#pragma once
6
7// platform includes
8#include <d3d11.h>
9#include <d3d11_4.h>
10#include <d3dcommon.h>
11#include <dwmapi.h>
12#include <dxgi.h>
13#include <dxgi1_6.h>
14#include <Unknwn.h>
15#include <winrt/windows.graphics.capture.h>
16
17// local includes
18#include "src/platform/common.h"
19#include "src/utility.h"
20#include "src/video.h"
21
22namespace platf::dxgi {
26 extern const std::array<const char *, 133> format_str;
27
28 // Add D3D11_CREATE_DEVICE_DEBUG here to enable the D3D11 debug runtime.
29 // You should have a debugger like WinDbg attached to receive debug messages.
30 auto constexpr D3D11_CREATE_DEVICE_FLAGS = 0;
31
37 template<class T>
38 void Release(T *dxgi) {
39 dxgi->Release();
40 }
41
162
163 namespace video {
188 } // namespace video
189
198
211 fp16_transfer_e select_fp16_transfer(DXGI_FORMAT format, bool hdr, bool gamma_encoded_sdr);
212
213 class hwdevice_t;
214
218 struct cursor_t {
219 std::vector<std::uint8_t> img_data;
220
221 DXGI_OUTDUPL_POINTER_SHAPE_INFO shape_info;
222 int x;
223 int y;
224 bool visible;
225 };
226
231 public:
235 gpu_cursor_t() = default;
236
247 void set_pos(LONG new_topleft_x, LONG new_topleft_y, LONG new_display_width, LONG new_display_height, DXGI_MODE_ROTATION new_display_rotation, bool new_visible) {
248 this->topleft_x = new_topleft_x;
249 this->topleft_y = new_topleft_y;
250 this->display_width = new_display_width;
251 this->display_height = new_display_height;
252 this->display_rotation = new_display_rotation;
253 this->visible = new_visible;
255 }
256
264 void set_texture(LONG new_texture_width, LONG new_texture_height, texture2d_t &&new_texture) {
265 this->texture = std::move(new_texture);
266 this->texture_width = new_texture_width;
267 this->texture_height = new_texture_height;
269 }
270
275 switch (display_rotation) {
276 case DXGI_MODE_ROTATION_UNSPECIFIED:
277 case DXGI_MODE_ROTATION_IDENTITY:
278 cursor_view.TopLeftX = topleft_x;
279 cursor_view.TopLeftY = topleft_y;
282 break;
283
284 case DXGI_MODE_ROTATION_ROTATE90:
285 cursor_view.TopLeftX = topleft_y;
288 cursor_view.Height = texture_width;
289 break;
290
291 case DXGI_MODE_ROTATION_ROTATE180:
296 break;
297
298 case DXGI_MODE_ROTATION_ROTATE270:
300 cursor_view.TopLeftY = topleft_x;
302 cursor_view.Height = texture_width;
303 break;
304 }
305 }
306
310
313
316 DXGI_MODE_ROTATION display_rotation;
317
319
320 D3D11_VIEWPORT cursor_view {0, 0, 0, 0, 0.0f, 1.0f};
321
322 bool visible;
323 };
324
328 class display_base_t: public display_t {
329 public:
337 int init(const ::video::config_t &config, const std::string &display_name);
338
339 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;
340
346 DXGI_RATIONAL display_refresh_rate;
348
349 DXGI_MODE_ROTATION display_rotation = DXGI_MODE_ROTATION_UNSPECIFIED;
352
355
356 DXGI_FORMAT capture_format;
357 D3D_FEATURE_LEVEL feature_level;
358
359 std::unique_ptr<high_precision_timer> timer = create_high_precision_timer();
360
372
374
378 using D3DKMT_HANDLE = UINT;
379
387
389
394 union {
395 struct
396 {
397 UINT HwSchSupported : 1;
398 UINT HwSchEnabled : 1;
399 UINT HwSchEnabledByDefault : 1;
401 UINT Reserved : 28;
402 };
403
404 UINT Value;
405 };
406 };
407
409
419
421
422 const UINT KMTQAITYPE_WDDM_2_7_CAPS = 70;
423
430
432
449
455 bool is_hdr() override;
462 bool get_hdr_metadata(SS_HDR_METADATA &metadata) override;
463
470 const char *dxgi_format_to_string(DXGI_FORMAT format);
477 const char *colorspace_to_string(DXGI_COLOR_SPACE_TYPE type);
483 virtual std::vector<DXGI_FORMAT> get_supported_capture_formats() = 0;
484
485 protected:
491 int get_pixel_pitch() const {
492 return (capture_format == DXGI_FORMAT_R16G16B16A16_FLOAT) ? 8 : 4;
493 }
494
504 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;
518 virtual int complete_img(img_t *img, bool dummy) = 0;
519 };
520
525 public:
531 std::shared_ptr<img_t> alloc_img() override;
538 int dummy_img(img_t *img) override;
546 int complete_img(img_t *img, bool dummy) override;
552 std::vector<DXGI_FORMAT> get_supported_capture_formats() override;
553
560 std::unique_ptr<avcodec_encode_device_t> make_avcodec_encode_device(pix_fmt_e pix_fmt) override;
561
562 D3D11_MAPPED_SUBRESOURCE img_info;
564 };
565
569 class display_vram_t: public display_base_t, public std::enable_shared_from_this<display_vram_t> {
570 public:
576 std::shared_ptr<img_t> alloc_img() override;
583 int dummy_img(img_t *img_base) override;
591 int complete_img(img_t *img_base, bool dummy) override;
597 std::vector<DXGI_FORMAT> get_supported_capture_formats() override;
598
599 bool is_codec_supported(std::string_view name, const ::video::config_t &config) override;
600
607 std::unique_ptr<avcodec_encode_device_t> make_avcodec_encode_device(pix_fmt_e pix_fmt) override;
608
615 std::unique_ptr<nvenc_encode_device_t> make_nvenc_encode_device(pix_fmt_e pix_fmt) override;
616
617 std::atomic<uint32_t> next_image_id;
618 };
619
624 public:
626 bool has_frame {};
627 std::chrono::steady_clock::time_point last_protected_content_warning_time {};
628
636 int init(display_base_t *display, const ::video::config_t &config);
645 capture_e next_frame(DXGI_OUTDUPL_FRAME_INFO &frame_info, std::chrono::milliseconds timeout, resource_t::pointer *res_p);
659
661 };
662
667 public:
675 int init(const ::video::config_t &config, const std::string &display_name);
685 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) override;
691 capture_e release_snapshot() override;
692
695 };
696
701 public:
709 int init(const ::video::config_t &config, const std::string &display_name);
719 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) override;
725 capture_e release_snapshot() override;
726
729
733
736
739
741 std::chrono::steady_clock::time_point old_surface_timestamp;
742 std::variant<std::monostate, texture2d_t, std::shared_ptr<platf::img_t>> last_frame_variant;
743 };
744
748 class wgc_capture_t {
749 winrt::Windows::Graphics::DirectX::Direct3D11::IDirect3DDevice uwp_device {nullptr};
750 winrt::Windows::Graphics::Capture::GraphicsCaptureItem item {nullptr};
751 winrt::Windows::Graphics::Capture::Direct3D11CaptureFramePool frame_pool {nullptr};
752 winrt::Windows::Graphics::Capture::GraphicsCaptureSession capture_session {nullptr};
753 winrt::Windows::Graphics::Capture::Direct3D11CaptureFrame produced_frame {nullptr};
754 winrt::Windows::Graphics::Capture::Direct3D11CaptureFrame consumed_frame {nullptr};
755 SRWLOCK frame_lock = SRWLOCK_INIT;
756 CONDITION_VARIABLE frame_present_cv;
757
758 void on_frame_arrived(winrt::Windows::Graphics::Capture::Direct3D11CaptureFramePool const &sender, winrt::Windows::Foundation::IInspectable const &);
759
760 public:
761 wgc_capture_t();
762 ~wgc_capture_t();
763
771 int init(display_base_t *display, const ::video::config_t &config);
780 capture_e next_frame(std::chrono::milliseconds timeout, ID3D11Texture2D **out, uint64_t &out_time);
793 int set_cursor_visible(bool cursor_visible);
794 };
795
800 wgc_capture_t dup;
801
802 public:
810 int init(const ::video::config_t &config, const std::string &display_name);
820 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) override;
826 capture_e release_snapshot() override;
827 };
828
833 wgc_capture_t dup;
834
835 public:
843 int init(const ::video::config_t &config, const std::string &display_name);
853 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) override;
859 capture_e release_snapshot() override;
860 };
861} // namespace platf::dxgi
std::function< bool(std::shared_ptr< img_t > &&img, bool frame_captured)> push_captured_image_cb_t
Callback for when a new image is ready. When display has a new image ready or a timeout occurs,...
Definition common.h:703
std::function< bool(std::shared_ptr< img_t > &img_out)> pull_free_image_cb_t
Get free image from pool. Calls must be synchronized. Blocks until there is free image in the pool or...
Definition common.h:712
Shared D3D11/DXGI state used by Windows display capture backends.
Definition display.h:328
DXGI_MODE_ROTATION display_rotation
Display rotation.
Definition display.h:349
device_t device
D3D11 device used for desktop duplication capture.
Definition display.h:344
NTSTATUS(WINAPI *)(HANDLE, D3DKMT_SCHEDULINGPRIORITYCLASS) PD3DKMTSetProcessSchedulingPriorityClass
Function pointer for setting D3DKMT process scheduling priority.
Definition display.h:436
output_t output
DXGI output duplicated for capture.
Definition display.h:343
_D3DKMT_SCHEDULINGPRIORITYCLASS D3DKMT_SCHEDULINGPRIORITYCLASS
Process scheduling priority class passed to D3DKMT.
Definition display.h:373
const char * colorspace_to_string(DXGI_COLOR_SPACE_TYPE type)
Convert a DXGI colorspace enum to a diagnostic string.
Definition display_base.cpp:986
const UINT KMTQAITYPE_WDDM_2_7_CAPS
Protocol or platform constant for kmtqaitype wddm 2 7 caps.
Definition display.h:422
D3D_FEATURE_LEVEL feature_level
Feature level.
Definition display.h:357
int client_frame_rate
Client frame rate.
Definition display.h:353
int display_refresh_rate_rounded
Display refresh rate rounded.
Definition display.h:347
bool is_hdr() override
Report whether the active display mode is HDR.
Definition display_base.cpp:773
virtual std::vector< DXGI_FORMAT > get_supported_capture_formats()=0
Get supported capture formats.
std::unique_ptr< high_precision_timer > timer
Timer.
Definition display.h:359
_D3DKMT_CLOSEADAPTER D3DKMT_CLOSEADAPTER
Adapter-close request passed to D3DKMT.
Definition display.h:431
const char * dxgi_format_to_string(DXGI_FORMAT format)
Convert a DXGI format enum to a diagnostic string.
Definition display_base.cpp:982
virtual int complete_img(img_t *img, bool dummy)=0
Finish cursor composition into a RAM-backed image.
NTSTATUS(WINAPI *)(D3DKMT_CLOSEADAPTER *) PD3DKMTCloseAdapter
Function pointer for closing a D3DKMT adapter handle.
Definition display.h:448
int get_pixel_pitch() const
Get pixel pitch.
Definition display.h:491
bool get_hdr_metadata(SS_HDR_METADATA &metadata) override
Read HDR metadata for the active display mode.
Definition display_base.cpp:788
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.
Definition display_base.cpp:225
int init(const ::video::config_t &config, const std::string &display_name)
Initialize D3D11 desktop duplication for the selected output.
Definition display_base.cpp:463
int width_before_rotation
Width before rotation.
Definition display.h:350
DXGI_FORMAT capture_format
Capture format.
Definition display.h:356
_D3DKMT_SCHEDULINGPRIORITYCLASS
Enumerates supported d3 DKMT SCHEDULINGPRIORITYCLASS options.
Definition display.h:364
@ D3DKMT_SCHEDULINGPRIORITYCLASS_NORMAL
Normal priority class.
Definition display.h:367
@ D3DKMT_SCHEDULINGPRIORITYCLASS_BELOW_NORMAL
Below normal priority class.
Definition display.h:366
@ D3DKMT_SCHEDULINGPRIORITYCLASS_HIGH
High priority class.
Definition display.h:369
@ D3DKMT_SCHEDULINGPRIORITYCLASS_IDLE
Idle priority class.
Definition display.h:365
@ D3DKMT_SCHEDULINGPRIORITYCLASS_REALTIME
Realtime priority class.
Definition display.h:370
@ D3DKMT_SCHEDULINGPRIORITYCLASS_ABOVE_NORMAL
Above normal priority class.
Definition display.h:368
adapter_t adapter
DXGI adapter containing the selected output.
Definition display.h:342
_D3DKMT_WDDM_2_7_CAPS D3DKMT_WDDM_2_7_CAPS
WDDM 2.7 capability flags returned by D3DKMT.
Definition display.h:408
DXGI_RATIONAL client_frame_rate_strict
Client frame rate strict.
Definition display.h:354
int height_before_rotation
Height before rotation.
Definition display.h:351
virtual capture_e release_snapshot()=0
Release resources associated with the last captured snapshot.
NTSTATUS(WINAPI *)(D3DKMT_QUERYADAPTERINFO *) PD3DKMTQueryAdapterInfo
Function pointer for querying D3DKMT adapter information.
Definition display.h:444
factory1_t factory
DXGI factory used to enumerate adapters and outputs.
Definition display.h:341
_D3DKMT_OPENADAPTERFROMLUID D3DKMT_OPENADAPTERFROMLUID
Adapter-open request passed to D3DKMT.
Definition display.h:388
device_ctx_t device_ctx
D3D11 device context used for copy and render operations.
Definition display.h:345
NTSTATUS(WINAPI *)(D3DKMT_OPENADAPTERFROMLUID *) PD3DKMTOpenAdapterFromLuid
Function pointer for opening a D3DKMT adapter by LUID.
Definition display.h:440
_D3DKMT_QUERYADAPTERINFO D3DKMT_QUERYADAPTERINFO
Adapter-information query passed to D3DKMT.
Definition display.h:420
DXGI_RATIONAL display_refresh_rate
Display refresh rate.
Definition display.h:346
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.
UINT D3DKMT_HANDLE
Kernel-mode D3DKMT adapter handle.
Definition display.h:378
Definition display.h:666
int init(const ::video::config_t &config, const std::string &display_name)
Initialize shared D3D capture resources for a RAM frame.
Definition display_ram.cpp:413
capture_e release_snapshot() override
Release resources associated with the last captured snapshot.
Definition display_ram.cpp:355
duplication_t dup
Desktop Duplication session used to acquire frames.
Definition display.h:693
cursor_t cursor
Cursor.
Definition display.h:694
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) override
Capture a display frame into the provided image object.
Definition display_ram.cpp:208
Definition display.h:700
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) override
Capture a display frame into the provided image object.
Definition display_vram.cpp:1366
duplication_t dup
Desktop Duplication session used to acquire frames.
Definition display.h:727
std::variant< std::monostate, texture2d_t, std::shared_ptr< platf::img_t > > last_frame_variant
Last frame variant.
Definition display.h:742
blend_t blend_alpha
Blend alpha.
Definition display.h:730
capture_e release_snapshot() override
Release resources associated with the last captured snapshot.
Definition display_vram.cpp:1774
int init(const ::video::config_t &config, const std::string &display_name)
Initialize D3D cursor rendering resources for RAM capture.
Definition display_vram.cpp:1778
gpu_cursor_t cursor_xor
Cursor xor.
Definition display.h:738
std::chrono::steady_clock::time_point old_surface_timestamp
Old surface timestamp.
Definition display.h:741
texture2d_t old_surface_delayed_destruction
Old surface delayed destruction.
Definition display.h:740
ps_t cursor_ps
Cursor ps.
Definition display.h:734
blend_t blend_invert
Blend invert.
Definition display.h:731
vs_t cursor_vs
Cursor vs.
Definition display.h:735
sampler_state_t sampler_linear
Sampler linear.
Definition display.h:728
gpu_cursor_t cursor_alpha
Cursor alpha.
Definition display.h:737
blend_t blend_disable
Blend disable.
Definition display.h:732
Definition display.h:524
std::shared_ptr< img_t > alloc_img() override
Allocate an image buffer compatible with this display backend.
Definition display_ram.cpp:359
std::unique_ptr< avcodec_encode_device_t > make_avcodec_encode_device(pix_fmt_e pix_fmt) override
Create AVCodec encode device.
Definition display_ram.cpp:421
D3D11_MAPPED_SUBRESOURCE img_info
CPU mapping information for the captured texture.
Definition display.h:562
int complete_img(img_t *img, bool dummy) override
Finish cursor composition into a GPU-backed image.
Definition display_ram.cpp:369
texture2d_t texture
D3D11 texture backing the captured frame.
Definition display.h:563
int dummy_img(img_t *img) override
Populate a fallback image when real capture data is unavailable.
std::vector< DXGI_FORMAT > get_supported_capture_formats() override
Get supported capture formats.
Definition display_ram.cpp:409
Definition display.h:569
std::vector< DXGI_FORMAT > get_supported_capture_formats() override
Get supported capture formats.
Definition display_vram.cpp:2025
std::unique_ptr< nvenc_encode_device_t > make_nvenc_encode_device(pix_fmt_e pix_fmt) override
Create NVENC encode device.
Definition display_vram.cpp:2147
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.
Definition display_vram.cpp:2055
int dummy_img(img_t *img_base) override
Populate a fallback image when real capture data is unavailable.
std::shared_ptr< img_t > alloc_img() override
Allocate an image buffer compatible with this display backend.
Definition display_vram.cpp:1925
std::atomic< uint32_t > next_image_id
Next image ID.
Definition display.h:617
int complete_img(img_t *img_base, bool dummy) override
Finalize a VRAM image after capture or dummy-frame generation.
Definition display_vram.cpp:1938
std::unique_ptr< avcodec_encode_device_t > make_avcodec_encode_device(pix_fmt_e pix_fmt) override
Create AVCodec encode device.
Definition display_vram.cpp:2139
Definition display.h:799
int init(const ::video::config_t &config, const std::string &display_name)
Initialize shared D3D capture resources for a GPU frame.
Definition display_wgc.cpp:255
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) override
Capture a display frame into the provided image object.
Definition display_wgc.cpp:267
capture_e release_snapshot() override
Release resources associated with the last captured snapshot.
Definition display_wgc.cpp:352
Definition display.h:832
capture_e release_snapshot() override
Release resources associated with the last captured snapshot.
Definition display_vram.cpp:1913
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) override
Capture a display frame into the provided image object.
Definition display_vram.cpp:1860
int init(const ::video::config_t &config, const std::string &display_name)
Initialize Windows Graphics Capture frame-pool resources.
Definition display_vram.cpp:1917
Definition display.h:623
dup_t dup
Desktop Duplication capture session.
Definition display.h:625
capture_e next_frame(DXGI_OUTDUPL_FRAME_INFO &frame_info, std::chrono::milliseconds timeout, resource_t::pointer *res_p)
Acquire the next frame from the Windows capture backend.
Definition display_base.cpp:150
bool has_frame
Whether a frame is currently held by the duplication object.
Definition display.h:626
capture_e release_frame()
Release resources associated with frame.
Definition display_base.cpp:195
std::chrono::steady_clock::time_point last_protected_content_warning_time
Last protected content warning time.
Definition display.h:627
capture_e reset(dup_t::pointer dup_p=dup_t::pointer())
Reset the object to its initial empty state.
Definition display_base.cpp:182
GPU resources used to render a captured cursor shape.
Definition display.h:230
gpu_cursor_t()=default
Initialize a cursor viewport with no area and the full depth range.
LONG topleft_y
Topleft y.
Definition display.h:312
LONG display_height
Display height.
Definition display.h:315
LONG texture_width
Texture width.
Definition display.h:308
void set_pos(LONG new_topleft_x, LONG new_topleft_y, LONG new_display_width, LONG new_display_height, DXGI_MODE_ROTATION new_display_rotation, bool new_visible)
Update the cursor position and display geometry used for rendering.
Definition display.h:247
shader_res_t input_res
Input res.
Definition display.h:318
LONG display_width
Display width.
Definition display.h:314
void set_texture(LONG new_texture_width, LONG new_texture_height, texture2d_t &&new_texture)
Replace the cursor texture and update its render viewport.
Definition display.h:264
LONG texture_height
Texture height.
Definition display.h:309
DXGI_MODE_ROTATION display_rotation
Display rotation.
Definition display.h:316
void update_viewport()
Recalculate the D3D viewport for the cursor texture.
Definition display.h:274
D3D11_VIEWPORT cursor_view
Cursor view with the full depth range.
Definition display.h:320
bool visible
Whether the cursor is visible.
Definition display.h:322
LONG topleft_x
Topleft x.
Definition display.h:311
texture2d_t texture
D3D11 texture backing the captured frame.
Definition display.h:307
Definition display.h:748
capture_e next_frame(std::chrono::milliseconds timeout, ID3D11Texture2D **out, uint64_t &out_time)
Acquire the next frame from the Windows capture backend.
Definition display_wgc.cpp:205
capture_e release_frame()
Release resources associated with frame.
Definition display_wgc.cpp:236
int set_cursor_visible(bool cursor_visible)
Enable or disable cursor composition in Windows.Graphics.Capture frames.
Definition display_wgc.cpp:244
int init(display_base_t *display, const ::video::config_t &config)
Initialize D3D cursor rendering resources for GPU capture.
Definition display_wgc.cpp:103
element_type * pointer
Definition utility.h:823
Declarations for common platform specific utilities.
std::shared_ptr< display_t > 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 monit...
Definition misc.cpp:1365
pix_fmt_e
Enumerates supported pix fmt options.
Definition common.h:342
std::unique_ptr< high_precision_timer > create_high_precision_timer()
Create platform-specific timer capable of high-precision sleep.
Definition misc.cpp:1550
capture_e
Enumerates supported capture options.
Definition common.h:683
@ timeout
Timeout.
Definition common.h:686
util::safe_ptr< IDXGIResource, &Release< IDXGIResource > > resource_t
Owning COM pointer for the DXGI resource view of a shared texture.
Definition display.h:101
util::safe_ptr< IDXGIOutputDuplication, &Release< IDXGIOutputDuplication > > dup_t
Owning COM pointer for the DXGI desktop duplication session.
Definition display.h:89
util::safe_ptr< ID3D11Buffer, &Release< ID3D11Buffer > > buf_t
Owning COM pointer for a D3D11 buffer.
Definition display.h:137
util::safe_ptr< ID3D11DeviceContext, &Release< ID3D11DeviceContext > > device_ctx_t
Owning COM pointer for the immediate D3D11 device context.
Definition display.h:65
util::safe_ptr< ID3D11VideoDevice, &Release< ID3D11VideoDevice > > device_t
Owning COM pointer for the D3D11 video device interface.
Definition display.h:167
util::safe_ptr< ID3D11Device1, &Release< ID3D11Device1 > > device1_t
Owning COM pointer for the D3D11.1 device interface.
Definition display.h:61
util::safe_ptr< ID3D11PixelShader, &Release< ID3D11PixelShader > > ps_t
Owning COM pointer for a D3D11 pixel shader.
Definition display.h:117
fp16_transfer_e
Transfer handling applied by the shaders that convert FP16 captures.
Definition display.h:193
@ gamma_encoded
Input is already sRGB gamma-encoded; apply no transfer curve.
Definition display.h:196
@ linear
Linear scRGB input; apply the sRGB curve.
Definition display.h:194
@ perceptual_quantizer
Linear scRGB input; encode with the Rec. 2100 PQ curve.
Definition display.h:195
util::safe_ptr< IDXGIOutput, &Release< IDXGIOutput > > output_t
Owning COM pointer for a DXGI output.
Definition display.h:73
util::safe_ptr< ID3D11VideoProcessorOutputView, &Release< ID3D11VideoProcessorOutputView > > processor_out_t
Owning COM pointer for a video processor output view.
Definition display.h:179
util::safe_ptr< ID3D11VideoContext, &Release< ID3D11VideoContext > > ctx_t
Owning COM pointer for the D3D11 video context interface.
Definition display.h:171
util::safe_ptr< ID3D11BlendState, &Release< ID3D11BlendState > > blend_t
Owning COM pointer for a D3D11 blend state.
Definition display.h:121
util::safe_ptr< ID3D11VertexShader, &Release< ID3D11VertexShader > > vs_t
Owning COM pointer for a D3D11 vertex shader.
Definition display.h:113
util::safe_ptr< ID3D11DepthStencilState, &Release< ID3D11DepthStencilState > > depth_stencil_state_t
D3D depth-stencil state handle type.
Definition display.h:153
util::safe_ptr< ID3D11RasterizerState, &Release< ID3D11RasterizerState > > raster_state_t
D3D rasterizer state handle type.
Definition display.h:141
util::safe_ptr< ID3D11InputLayout, &Release< ID3D11InputLayout > > input_layout_t
Owning COM pointer for a D3D11 input layout.
Definition display.h:125
util::safe_ptr< ID3D11Multithread, &Release< ID3D11Multithread > > multithread_t
Owning COM pointer for the D3D11 multithread-protection interface.
Definition display.h:109
util::safe_ptr< IDXGIDevice1, &Release< IDXGIDevice1 > > dxgi1_t
Owning COM pointer for a DXGI 1.1 device interface.
Definition display.h:53
util::safe_ptr< ID3D11Device, &Release< ID3D11Device > > device_t
Owning COM pointer for the D3D11 device used by capture and conversion.
Definition display.h:57
util::safe_ptr< IDXGIOutput5, &Release< IDXGIOutput5 > > output5_t
Owning COM pointer for a DXGI output with HDR metadata support.
Definition display.h:81
util::safe_ptr< ID3D11VideoProcessorInputView, &Release< ID3D11VideoProcessorInputView > > processor_in_t
Owning COM pointer for a video processor input view.
Definition display.h:183
util::safe_ptr< ID3D11Texture1D, &Release< ID3D11Texture1D > > texture1d_t
Owning COM pointer for a D3D11 1D texture.
Definition display.h:97
auto constexpr D3D11_CREATE_DEVICE_FLAGS
Protocol or platform constant for d3 d11 create device flags.
Definition display.h:30
util::safe_ptr< ID3D11DepthStencilView, &Release< ID3D11DepthStencilView > > depth_stencil_view_t
Owning COM pointer for a D3D11 depth-stencil view.
Definition display.h:157
util::safe_ptr< ID3D11RenderTargetView, &Release< ID3D11RenderTargetView > > render_target_t
Owning COM pointer for a D3D11 render-target view.
Definition display.h:129
util::safe_ptr< IDXGIKeyedMutex, &Release< IDXGIKeyedMutex > > keyed_mutex_t
Owning COM pointer for a keyed mutex on a shared DXGI resource.
Definition display.h:161
util::safe_ptr< IDXGIOutput1, &Release< IDXGIOutput1 > > output1_t
Owning COM pointer for a DXGI output that supports duplication.
Definition display.h:77
util::safe_ptr< IDXGIFactory1, &Release< IDXGIFactory1 > > factory1_t
Owning COM pointer for the DXGI factory used to enumerate adapters.
Definition display.h:45
void Release(T *dxgi)
Release the COM or platform reference owned by the pointer.
Definition display.h:38
util::safe_ptr< ID3D11ShaderResourceView, &Release< ID3D11ShaderResourceView > > shader_res_t
Owning COM pointer for a D3D11 shader-resource view.
Definition display.h:133
util::safe_ptr< IDXGIDevice, &Release< IDXGIDevice > > dxgi_t
Owning COM pointer for a DXGI device interface.
Definition display.h:49
util::safe_ptr< IDXGIAdapter1, &Release< IDXGIAdapter1 > > adapter_t
Owning COM pointer for a DXGI display adapter.
Definition display.h:69
util::safe_ptr< ID3D11VideoProcessorEnumerator, &Release< ID3D11VideoProcessorEnumerator > > processor_enum_t
Owning COM pointer for a video processor capability enumerator.
Definition display.h:187
util::safe_ptr< ID3D11SamplerState, &Release< ID3D11SamplerState > > sampler_state_t
D3D sampler state handle type.
Definition display.h:145
util::safe_ptr< ID3D11Texture2D, &Release< ID3D11Texture2D > > texture2d_t
Owning COM pointer for a D3D11 2D texture.
Definition display.h:93
util::safe_ptr< IDXGIOutput6, &Release< IDXGIOutput6 > > output6_t
Owning COM pointer for a DXGI output with modern display descriptors.
Definition display.h:85
util::safe_ptr< ID3DBlob, &Release< ID3DBlob > > blob_t
Owning COM pointer for a compiled shader bytecode blob.
Definition display.h:149
util::safe_ptr< IDXGIResource1, &Release< IDXGIResource1 > > resource1_t
Owning COM pointer for the DXGI 1.1 resource sharing interface.
Definition display.h:105
util::safe_ptr< ID3D11VideoProcessor, &Release< ID3D11VideoProcessor > > processor_t
Owning COM pointer for a D3D11 video processor.
Definition display.h:175
const std::array< const char *, 133 > format_str
Diagnostic names indexed by DXGI_FORMAT.
Definition display_base.cpp:844
long NTSTATUS
Windows NT status code returned by native APIs.
Definition display_base.cpp:29
int init()
Initialize the Windows audio-control backend.
Definition display_vram.cpp:2158
Cursor position and visibility for the current capture frame.
Definition display.h:218
bool visible
Whether the cursor is visible.
Definition display.h:224
std::vector< std::uint8_t > img_data
Raw pointer-shape bytes from DXGI output duplication.
Definition display.h:219
DXGI_OUTDUPL_POINTER_SHAPE_INFO shape_info
Shape info.
Definition display.h:221
int x
X.
Definition display.h:222
int y
Y.
Definition display.h:223
Win32 D3DKMT adapter-close request structure.
Definition display.h:427
D3DKMT_HANDLE hAdapter
D3DKMT adapter handle used for low-level display queries.
Definition display.h:428
Win32 D3DKMT adapter-open request structure.
Definition display.h:383
D3DKMT_HANDLE hAdapter
D3DKMT adapter handle used for low-level display queries.
Definition display.h:385
LUID AdapterLuid
Adapter luid.
Definition display.h:384
Win32 D3DKMT adapter information query.
Definition display.h:413
D3DKMT_HANDLE hAdapter
D3DKMT adapter handle used for low-level display queries.
Definition display.h:414
VOID * pPrivateDriverData
P private driver data.
Definition display.h:416
UINT PrivateDriverDataSize
Private driver data size.
Definition display.h:417
Win32 D3DKMT WDDM 2.7 capability flags.
Definition display.h:393
Captured frame buffer shared between capture and encode stages.
Definition display_ram.cpp:18
UINT Value
Packed representation of the WDDM 2.7 capability flags.
Declarations for utility functions.
uniq_ptr< T, Destroy< T *, void, function > > safe_ptr
Unique pointer using a compile-time C-style destroy function.
Definition utility.h:1590
Declarations for video.