Sunshine master
Self-hosted game stream host for Moonlight.
platf::dxgi::d3d_base_encode_device Class Referencefinal

Shared D3D11 conversion resources for AVCodec and NVENC encode devices. More...

Collaboration diagram for platf::dxgi::d3d_base_encode_device:
[legend]

Classes

struct  encoder_img_ctx_t
 D3D texture and format information for encoder input. More...
 

Public Member Functions

void apply_colorspace (const ::video::sunshine_colorspace_t &colorspace)
 Apply the configured colorspace metadata to the active frame.
 
int convert (platf::img_t &img_base)
 Convert a captured D3D image into encoder input textures.
 
shader_res_t create_black_texture_for_rtv_clear ()
 Create black texture for rtv clear.
 
int init (std::shared_ptr< platf::display_t > display, adapter_t::pointer adapter_p, pix_fmt_e pix_fmt)
 Initialize shared D3D conversion resources for the encoder.
 
int init_output (ID3D11Texture2D *frame_texture, int width, int height)
 Create D3D11 output textures, views, and shaders for frame conversion.
 
int initialize_image_context (const img_d3d_t &img, encoder_img_ctx_t &img_ctx)
 Initialize encoder-side D3D resources for a captured image.
 

Public Attributes

blend_t blend_disable
 Blend disable.
 
buf_t color_matrix
 Color matrix.
 
::video::color_tcolor_p
 Color p.
 
ps_t convert_UV_fp16_ps
 Convert UV fp16 ps.
 
ps_t convert_UV_ps
 Convert UV ps.
 
vs_t convert_UV_vs
 Convert UV vs.
 
ps_t convert_Y_or_YUV_fp16_ps
 Convert y or YUV fp16 ps.
 
ps_t convert_Y_or_YUV_ps
 Convert y or YUV ps.
 
vs_t convert_Y_or_YUV_vs
 Convert y or YUV vs.
 
device_t device
 D3D11 device used for encoder-side texture conversion.
 
device_ctx_t device_ctx
 D3D11 device context used to issue conversion commands.
 
std::shared_ptr< display_base_tdisplay
 Display capture backend that supplies source textures.
 
DXGI_FORMAT format
 DXGI format required by the encoder input texture.
 
std::map< uint32_t, encoder_img_ctx_timg_ctx_map
 Encoder resources cached by captured image ID.
 
render_target_t out_UV_rtv
 Out UV rtv.
 
D3D11_VIEWPORT out_UV_viewport
 Out UV viewport.
 
D3D11_VIEWPORT out_UV_viewport_for_clear
 Out UV viewport for clear.
 
render_target_t out_Y_or_YUV_rtv
 Out y or YUV rtv.
 
std::array< D3D11_VIEWPORT, 3 > out_Y_or_YUV_viewports
 Out y or YUV viewports.
 
std::array< D3D11_VIEWPORT, 3 > out_Y_or_YUV_viewports_for_clear
 Out y or YUV viewports for clear.
 
texture2d_t output_texture
 Output texture.
 
bool rtvs_cleared = false
 Whether render-target views have been cleared for the frame.
 
sampler_state_t sampler_linear
 Sampler linear.
 
buf_t subsample_offset
 Subsample offset.
 

Detailed Description

Shared D3D11 conversion resources for AVCodec and NVENC encode devices.

Member Function Documentation

◆ apply_colorspace()

void platf::dxgi::d3d_base_encode_device::apply_colorspace ( const ::video::sunshine_colorspace_t & colorspace)
inline

Apply the configured colorspace metadata to the active frame.

Parameters
colorspaceColorimetry information used for conversion or encoding.

◆ convert()

int platf::dxgi::d3d_base_encode_device::convert ( platf::img_t & img_base)
inline

Convert a captured D3D image into encoder input textures.

Parameters
img_baseD3D image supplied by the capture backend.
Returns
Conversion status.

◆ create_black_texture_for_rtv_clear()

shader_res_t platf::dxgi::d3d_base_encode_device::create_black_texture_for_rtv_clear ( )
inline

Create black texture for rtv clear.

Returns
Created black texture for rtv clear object or status.

◆ init()

int platf::dxgi::d3d_base_encode_device::init ( std::shared_ptr< platf::display_t > display,
adapter_t::pointer adapter_p,
pix_fmt_e pix_fmt )
inline

Initialize shared D3D conversion resources for the encoder.

Parameters
displayDisplay object or identifier associated with the operation.
adapter_pAdapter p.
pix_fmtSunshine pixel format to convert or allocate for.
Returns
0 on success; nonzero or negative platform status on failure.

◆ init_output()

int platf::dxgi::d3d_base_encode_device::init_output ( ID3D11Texture2D * frame_texture,
int width,
int height )
inline

Create D3D11 output textures, views, and shaders for frame conversion.

Parameters
frame_textureFrame texture.
widthFrame or display width in pixels.
heightFrame or display height in pixels.
Returns
0 when output resources are initialized; nonzero on D3D failure.

◆ initialize_image_context()

int platf::dxgi::d3d_base_encode_device::initialize_image_context ( const img_d3d_t & img,
encoder_img_ctx_t & img_ctx )
inline

Initialize encoder-side D3D resources for a captured image.

Parameters
imgImage or frame object to read from or populate.
img_ctxCached encoder resources associated with the image ID.
Returns
0 when the shared texture is opened and bound; nonzero on D3D failure.

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