mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 09:55:36 +00:00
d3d11device: Remove optional helper methods
Most of Direct3D11 APIs can be called without GstD3D11Device abstraction. This is a part of prework for public GstD3D11 library to introduce minimal APIs Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1892>
This commit is contained in:
parent
28174b14d3
commit
ac04681b6f
8 changed files with 175 additions and 290 deletions
|
@ -568,6 +568,7 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
|||
guint aligned_width, aligned_height;
|
||||
guint alignment;
|
||||
GstD3D11DeviceVendor vendor;
|
||||
ID3D11Device *device_handle;
|
||||
|
||||
g_return_val_if_fail (GST_IS_D3D11_DECODER (decoder), FALSE);
|
||||
g_return_val_if_fail (codec > GST_D3D11_CODEC_NONE, FALSE);
|
||||
|
@ -583,6 +584,8 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
|||
decoder->opened = FALSE;
|
||||
priv->use_array_of_texture = FALSE;
|
||||
|
||||
device_handle = gst_d3d11_device_get_device_handle (priv->device);
|
||||
|
||||
d3d11_format = gst_d3d11_device_format_from_gst (priv->device,
|
||||
GST_VIDEO_INFO_FORMAT (info));
|
||||
if (!d3d11_format || d3d11_format->dxgi_format == DXGI_FORMAT_UNKNOWN) {
|
||||
|
@ -749,9 +752,9 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
|||
staging_desc.Usage = D3D11_USAGE_STAGING;
|
||||
staging_desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
|
||||
|
||||
priv->staging = gst_d3d11_device_create_texture (priv->device,
|
||||
&staging_desc, NULL);
|
||||
if (!priv->staging) {
|
||||
hr = ID3D11Device_CreateTexture2D (device_handle, &staging_desc, NULL,
|
||||
&priv->staging);
|
||||
if (!gst_d3d11_result (hr, priv->device)) {
|
||||
GST_ERROR_OBJECT (decoder, "Couldn't create staging texture");
|
||||
goto error;
|
||||
}
|
||||
|
@ -803,17 +806,17 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
|||
texture_desc.Usage = D3D11_USAGE_DEFAULT;
|
||||
texture_desc.BindFlags = D3D11_BIND_RENDER_TARGET;
|
||||
|
||||
priv->fallback_shader_output_texture =
|
||||
gst_d3d11_device_create_texture (priv->device, &texture_desc, NULL);
|
||||
if (!priv->fallback_shader_output_texture) {
|
||||
hr = ID3D11Device_CreateTexture2D (device_handle, &texture_desc, NULL,
|
||||
&priv->fallback_shader_output_texture);
|
||||
if (!gst_d3d11_result (hr, priv->device)) {
|
||||
GST_ERROR_OBJECT (decoder, "Couldn't create shader output texture");
|
||||
goto error;
|
||||
}
|
||||
|
||||
texture_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||
priv->shader_resource_texture =
|
||||
gst_d3d11_device_create_texture (priv->device, &texture_desc, NULL);
|
||||
if (!priv->shader_resource_texture) {
|
||||
hr = ID3D11Device_CreateTexture2D (device_handle, &texture_desc, NULL,
|
||||
&priv->shader_resource_texture);
|
||||
if (!gst_d3d11_result (hr, priv->device)) {
|
||||
GST_ERROR_OBJECT (decoder, "Couldn't create shader input texture");
|
||||
goto error;
|
||||
}
|
||||
|
|
|
@ -933,6 +933,14 @@ gst_d3d11_device_get_device_context_handle (GstD3D11Device * device)
|
|||
return device->priv->device_context;
|
||||
}
|
||||
|
||||
IDXGIFactory1 *
|
||||
gst_d3d11_device_get_dxgi_factory_handle (GstD3D11Device * device)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), NULL);
|
||||
|
||||
return device->priv->factory;
|
||||
}
|
||||
|
||||
GstD3D11DXGIFactoryVersion
|
||||
gst_d3d11_device_get_chosen_dxgi_factory_version (GstD3D11Device * device)
|
||||
{
|
||||
|
@ -950,236 +958,6 @@ gst_d3d11_device_get_chosen_feature_level (GstD3D11Device * device)
|
|||
return device->priv->feature_level;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_d3d11_device_create_swap_chain:
|
||||
* @device: a #GstD3D11Device
|
||||
* @desc: a DXGI_SWAP_CHAIN_DESC structure for swapchain
|
||||
*
|
||||
* Create a IDXGISwapChain object. Caller must release returned swap chain object
|
||||
* via IDXGISwapChain_Release()
|
||||
*
|
||||
* Returns: (transfer full) (nullable): a new IDXGISwapChain or %NULL
|
||||
* when failed to create swap chain with given @desc
|
||||
*/
|
||||
IDXGISwapChain *
|
||||
gst_d3d11_device_create_swap_chain (GstD3D11Device * device,
|
||||
const DXGI_SWAP_CHAIN_DESC * desc)
|
||||
{
|
||||
GstD3D11DevicePrivate *priv;
|
||||
HRESULT hr;
|
||||
IDXGISwapChain *swap_chain = NULL;
|
||||
|
||||
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), NULL);
|
||||
|
||||
priv = device->priv;
|
||||
|
||||
gst_d3d11_device_lock (device);
|
||||
hr = IDXGIFactory1_CreateSwapChain (priv->factory, (IUnknown *) priv->device,
|
||||
(DXGI_SWAP_CHAIN_DESC *) desc, &swap_chain);
|
||||
gst_d3d11_device_unlock (device);
|
||||
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_WARNING_OBJECT (device, "Cannot create SwapChain Object: 0x%x",
|
||||
(guint) hr);
|
||||
swap_chain = NULL;
|
||||
}
|
||||
|
||||
return swap_chain;
|
||||
}
|
||||
|
||||
#if (DXGI_HEADER_VERSION >= 2)
|
||||
#if (!GST_D3D11_WINAPI_ONLY_APP)
|
||||
/**
|
||||
* gst_d3d11_device_create_swap_chain_for_hwnd:
|
||||
* @device: a #GstD3D11Device
|
||||
* @hwnd: HWND handle
|
||||
* @desc: a DXGI_SWAP_CHAIN_DESC1 structure for swapchain
|
||||
* @fullscreen_desc: (nullable): a DXGI_SWAP_CHAIN_FULLSCREEN_DESC
|
||||
* structure for swapchain
|
||||
* @output: (nullable): a IDXGIOutput interface for the output to restrict content to
|
||||
*
|
||||
* Create a IDXGISwapChain1 object. Caller must release returned swap chain object
|
||||
* via IDXGISwapChain1_Release()
|
||||
*
|
||||
* Returns: (transfer full) (nullable): a new IDXGISwapChain1 or %NULL
|
||||
* when failed to create swap chain with given @desc
|
||||
*/
|
||||
IDXGISwapChain1 *
|
||||
gst_d3d11_device_create_swap_chain_for_hwnd (GstD3D11Device * device,
|
||||
HWND hwnd, const DXGI_SWAP_CHAIN_DESC1 * desc,
|
||||
const DXGI_SWAP_CHAIN_FULLSCREEN_DESC * fullscreen_desc,
|
||||
IDXGIOutput * output)
|
||||
{
|
||||
GstD3D11DevicePrivate *priv;
|
||||
IDXGISwapChain1 *swap_chain = NULL;
|
||||
HRESULT hr;
|
||||
|
||||
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), NULL);
|
||||
|
||||
priv = device->priv;
|
||||
|
||||
gst_d3d11_device_lock (device);
|
||||
hr = IDXGIFactory2_CreateSwapChainForHwnd ((IDXGIFactory2 *) priv->factory,
|
||||
(IUnknown *) priv->device, hwnd, desc, fullscreen_desc,
|
||||
output, &swap_chain);
|
||||
gst_d3d11_device_unlock (device);
|
||||
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_WARNING_OBJECT (device, "Cannot create SwapChain Object: 0x%x",
|
||||
(guint) hr);
|
||||
swap_chain = NULL;
|
||||
}
|
||||
|
||||
return swap_chain;
|
||||
}
|
||||
#endif /* GST_D3D11_WINAPI_ONLY_APP */
|
||||
|
||||
#if GST_D3D11_WINAPI_ONLY_APP
|
||||
/**
|
||||
* gst_d3d11_device_create_swap_chain_for_core_window:
|
||||
* @device: a #GstD3D11Device
|
||||
* @core_window: CoreWindow handle
|
||||
* @desc: a DXGI_SWAP_CHAIN_DESC1 structure for swapchain
|
||||
* @output: (nullable): a IDXGIOutput interface for the output to restrict content to
|
||||
*
|
||||
* Create a IDXGISwapChain1 object. Caller must release returned swap chain object
|
||||
* via IDXGISwapChain1_Release()
|
||||
*
|
||||
* Returns: (transfer full) (nullable): a new IDXGISwapChain1 or %NULL
|
||||
* when failed to create swap chain with given @desc
|
||||
*/
|
||||
IDXGISwapChain1 *
|
||||
gst_d3d11_device_create_swap_chain_for_core_window (GstD3D11Device * device,
|
||||
guintptr core_window, const DXGI_SWAP_CHAIN_DESC1 * desc,
|
||||
IDXGIOutput * output)
|
||||
{
|
||||
GstD3D11DevicePrivate *priv;
|
||||
IDXGISwapChain1 *swap_chain = NULL;
|
||||
HRESULT hr;
|
||||
|
||||
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), NULL);
|
||||
|
||||
priv = device->priv;
|
||||
|
||||
gst_d3d11_device_lock (device);
|
||||
hr = IDXGIFactory2_CreateSwapChainForCoreWindow ((IDXGIFactory2 *)
|
||||
priv->factory, (IUnknown *) priv->device, (IUnknown *) core_window, desc,
|
||||
output, &swap_chain);
|
||||
gst_d3d11_device_unlock (device);
|
||||
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_WARNING_OBJECT (device, "Cannot create SwapChain Object: 0x%x",
|
||||
(guint) hr);
|
||||
swap_chain = NULL;
|
||||
}
|
||||
|
||||
return swap_chain;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_d3d11_device_create_swap_chain_for_composition:
|
||||
* @device: a #GstD3D11Device
|
||||
* @desc: a DXGI_SWAP_CHAIN_DESC1 structure for swapchain
|
||||
* @output: (nullable): a IDXGIOutput interface for the output to restrict content to
|
||||
*
|
||||
* Create a IDXGISwapChain1 object. Caller must release returned swap chain object
|
||||
* via IDXGISwapChain1_Release()
|
||||
*
|
||||
* Returns: (transfer full) (nullable): a new IDXGISwapChain1 or %NULL
|
||||
* when failed to create swap chain with given @desc
|
||||
*/
|
||||
IDXGISwapChain1 *
|
||||
gst_d3d11_device_create_swap_chain_for_composition (GstD3D11Device * device,
|
||||
const DXGI_SWAP_CHAIN_DESC1 * desc, IDXGIOutput * output)
|
||||
{
|
||||
GstD3D11DevicePrivate *priv;
|
||||
IDXGISwapChain1 *swap_chain = NULL;
|
||||
HRESULT hr;
|
||||
|
||||
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), NULL);
|
||||
|
||||
priv = device->priv;
|
||||
|
||||
gst_d3d11_device_lock (device);
|
||||
hr = IDXGIFactory2_CreateSwapChainForComposition ((IDXGIFactory2 *)
|
||||
priv->factory, (IUnknown *) priv->device, desc, output, &swap_chain);
|
||||
gst_d3d11_device_unlock (device);
|
||||
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_WARNING_OBJECT (device, "Cannot create SwapChain Object: 0x%x",
|
||||
(guint) hr);
|
||||
swap_chain = NULL;
|
||||
}
|
||||
|
||||
return swap_chain;
|
||||
}
|
||||
#endif /* GST_D3D11_WINAPI_ONLY_APP */
|
||||
#endif /* (DXGI_HEADER_VERSION >= 2) */
|
||||
|
||||
/**
|
||||
* gst_d3d11_device_release_swap_chain:
|
||||
* @device: a #GstD3D11Device
|
||||
* @swap_chain: a IDXGISwapChain
|
||||
*
|
||||
* Release a @swap_chain from device thread
|
||||
*/
|
||||
void
|
||||
gst_d3d11_device_release_swap_chain (GstD3D11Device * device,
|
||||
IDXGISwapChain * swap_chain)
|
||||
{
|
||||
g_return_if_fail (GST_IS_D3D11_DEVICE (device));
|
||||
g_return_if_fail (swap_chain != NULL);
|
||||
|
||||
gst_d3d11_device_lock (device);
|
||||
IDXGISwapChain_Release (swap_chain);
|
||||
gst_d3d11_device_unlock (device);
|
||||
}
|
||||
|
||||
ID3D11Texture2D *
|
||||
gst_d3d11_device_create_texture (GstD3D11Device * device,
|
||||
const D3D11_TEXTURE2D_DESC * desc,
|
||||
const D3D11_SUBRESOURCE_DATA * inital_data)
|
||||
{
|
||||
GstD3D11DevicePrivate *priv;
|
||||
HRESULT hr;
|
||||
ID3D11Texture2D *texture;
|
||||
|
||||
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), NULL);
|
||||
g_return_val_if_fail (desc != NULL, NULL);
|
||||
|
||||
priv = device->priv;
|
||||
|
||||
hr = ID3D11Device_CreateTexture2D (priv->device, desc, inital_data, &texture);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR ("Failed to create texture (0x%x)", (guint) hr);
|
||||
|
||||
GST_WARNING ("Direct3D11 Allocation params");
|
||||
GST_WARNING ("\t%dx%d, DXGI format %d",
|
||||
desc->Width, desc->Height, desc->Format);
|
||||
GST_WARNING ("\tMipLevel %d, ArraySize %d",
|
||||
desc->MipLevels, desc->ArraySize);
|
||||
GST_WARNING ("\tSampleDesc.Count %d, SampleDesc.Quality %d",
|
||||
desc->SampleDesc.Count, desc->SampleDesc.Quality);
|
||||
GST_WARNING ("\tUsage %d", desc->Usage);
|
||||
GST_WARNING ("\tBindFlags 0x%x", desc->BindFlags);
|
||||
GST_WARNING ("\tCPUAccessFlags 0x%x", desc->CPUAccessFlags);
|
||||
GST_WARNING ("\tMiscFlags 0x%x", desc->MiscFlags);
|
||||
texture = NULL;
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
void
|
||||
gst_d3d11_device_release_texture (GstD3D11Device * device,
|
||||
ID3D11Texture2D * texture)
|
||||
{
|
||||
g_return_if_fail (GST_IS_D3D11_DEVICE (device));
|
||||
g_return_if_fail (texture != NULL);
|
||||
|
||||
ID3D11Texture2D_Release (texture);
|
||||
}
|
||||
|
||||
void
|
||||
gst_d3d11_device_lock (GstD3D11Device * device)
|
||||
{
|
||||
|
|
|
@ -83,45 +83,12 @@ ID3D11Device * gst_d3d11_device_get_device_handle (GstD3D11Device * devi
|
|||
|
||||
ID3D11DeviceContext * gst_d3d11_device_get_device_context_handle (GstD3D11Device * device);
|
||||
|
||||
IDXGIFactory1 * gst_d3d11_device_get_dxgi_factory_handle (GstD3D11Device * device);
|
||||
|
||||
GstD3D11DXGIFactoryVersion gst_d3d11_device_get_chosen_dxgi_factory_version (GstD3D11Device * device);
|
||||
|
||||
D3D_FEATURE_LEVEL gst_d3d11_device_get_chosen_feature_level (GstD3D11Device * device);
|
||||
|
||||
IDXGISwapChain * gst_d3d11_device_create_swap_chain (GstD3D11Device * device,
|
||||
const DXGI_SWAP_CHAIN_DESC * desc);
|
||||
|
||||
#if (DXGI_HEADER_VERSION >= 2)
|
||||
#if (!GST_D3D11_WINAPI_ONLY_APP)
|
||||
IDXGISwapChain1 * gst_d3d11_device_create_swap_chain_for_hwnd (GstD3D11Device * device,
|
||||
HWND hwnd,
|
||||
const DXGI_SWAP_CHAIN_DESC1 * desc,
|
||||
const DXGI_SWAP_CHAIN_FULLSCREEN_DESC * fullscreen_desc,
|
||||
IDXGIOutput * output);
|
||||
#endif
|
||||
|
||||
#if GST_D3D11_WINAPI_ONLY_APP
|
||||
IDXGISwapChain1 * gst_d3d11_device_create_swap_chain_for_core_window (GstD3D11Device * device,
|
||||
guintptr core_window,
|
||||
const DXGI_SWAP_CHAIN_DESC1 * desc,
|
||||
IDXGIOutput * output);
|
||||
|
||||
IDXGISwapChain1 * gst_d3d11_device_create_swap_chain_for_composition (GstD3D11Device * device,
|
||||
const DXGI_SWAP_CHAIN_DESC1 * desc,
|
||||
IDXGIOutput * output);
|
||||
|
||||
#endif /* GST_D3D11_WINAPI_ONLY_APP */
|
||||
#endif /* (DXGI_HEADER_VERSION >= 2) */
|
||||
|
||||
void gst_d3d11_device_release_swap_chain (GstD3D11Device * device,
|
||||
IDXGISwapChain * swap_chain);
|
||||
|
||||
ID3D11Texture2D * gst_d3d11_device_create_texture (GstD3D11Device * device,
|
||||
const D3D11_TEXTURE2D_DESC * desc,
|
||||
const D3D11_SUBRESOURCE_DATA *inital_data);
|
||||
|
||||
void gst_d3d11_device_release_texture (GstD3D11Device * device,
|
||||
ID3D11Texture2D * texture);
|
||||
|
||||
void gst_d3d11_device_lock (GstD3D11Device * device);
|
||||
|
||||
void gst_d3d11_device_unlock (GstD3D11Device * device);
|
||||
|
|
|
@ -229,6 +229,9 @@ create_staging_texture (GstD3D11Device * device,
|
|||
const D3D11_TEXTURE2D_DESC * ref)
|
||||
{
|
||||
D3D11_TEXTURE2D_DESC desc = { 0, };
|
||||
ID3D11Texture2D *texture = NULL;
|
||||
ID3D11Device *device_handle = gst_d3d11_device_get_device_handle (device);
|
||||
HRESULT hr;
|
||||
|
||||
desc.Width = ref->Width;
|
||||
desc.Height = ref->Height;
|
||||
|
@ -239,7 +242,13 @@ create_staging_texture (GstD3D11Device * device,
|
|||
desc.Usage = D3D11_USAGE_STAGING;
|
||||
desc.CPUAccessFlags = (D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE);
|
||||
|
||||
return gst_d3d11_device_create_texture (device, &desc, NULL);
|
||||
hr = ID3D11Device_CreateTexture2D (device_handle, &desc, NULL, &texture);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR_OBJECT (device, "Failed to create texture");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -498,8 +507,8 @@ gst_d3d11_allocator_dispose (GObject * object)
|
|||
g_clear_pointer (&priv->decoder_output_view_array, g_array_unref);
|
||||
g_clear_pointer (&priv->processor_input_view_array, g_array_unref);
|
||||
|
||||
if (alloc->device && priv->texture) {
|
||||
gst_d3d11_device_release_texture (alloc->device, priv->texture);
|
||||
if (priv->texture) {
|
||||
ID3D11Texture2D_Release (priv->texture);
|
||||
priv->texture = NULL;
|
||||
}
|
||||
|
||||
|
@ -820,6 +829,8 @@ gst_d3d11_allocator_alloc (GstD3D11Allocator * allocator,
|
|||
guint index_to_use = 0;
|
||||
GstD3D11AllocatorPrivate *priv;
|
||||
GstD3D11MemoryType type = GST_D3D11_MEMORY_TYPE_TEXTURE;
|
||||
HRESULT hr;
|
||||
ID3D11Device *device_handle;
|
||||
|
||||
g_return_val_if_fail (GST_IS_D3D11_ALLOCATOR (allocator), NULL);
|
||||
g_return_val_if_fail (desc != NULL, NULL);
|
||||
|
@ -827,6 +838,7 @@ gst_d3d11_allocator_alloc (GstD3D11Allocator * allocator,
|
|||
|
||||
priv = allocator->priv;
|
||||
device = allocator->device;
|
||||
device_handle = gst_d3d11_device_get_device_handle (device);
|
||||
|
||||
if ((flags & GST_D3D11_ALLOCATION_FLAG_TEXTURE_ARRAY)) {
|
||||
gint i;
|
||||
|
@ -882,8 +894,9 @@ gst_d3d11_allocator_alloc (GstD3D11Allocator * allocator,
|
|||
GST_D3D11_ALLOCATOR_UNLOCK (allocator);
|
||||
|
||||
if (!priv->texture) {
|
||||
priv->texture = gst_d3d11_device_create_texture (device, desc, NULL);
|
||||
if (!priv->texture) {
|
||||
hr = ID3D11Device_CreateTexture2D (device_handle, desc, NULL,
|
||||
&priv->texture);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR_OBJECT (allocator, "Couldn't create texture");
|
||||
goto error;
|
||||
}
|
||||
|
@ -894,8 +907,8 @@ gst_d3d11_allocator_alloc (GstD3D11Allocator * allocator,
|
|||
|
||||
type = GST_D3D11_MEMORY_TYPE_ARRAY;
|
||||
} else {
|
||||
texture = gst_d3d11_device_create_texture (device, desc, NULL);
|
||||
if (!texture) {
|
||||
hr = ID3D11Device_CreateTexture2D (device_handle, desc, NULL, &texture);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR_OBJECT (allocator, "Couldn't create texture");
|
||||
goto error;
|
||||
}
|
||||
|
@ -917,7 +930,7 @@ gst_d3d11_allocator_alloc (GstD3D11Allocator * allocator,
|
|||
|
||||
error:
|
||||
if (texture)
|
||||
gst_d3d11_device_release_texture (device, texture);
|
||||
ID3D11Texture2D_Release (texture);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -969,7 +982,7 @@ gst_d3d11_allocator_alloc_staging (GstD3D11Allocator * allocator,
|
|||
|
||||
error:
|
||||
if (texture)
|
||||
gst_d3d11_device_release_texture (device, texture);
|
||||
ID3D11Texture2D_Release (texture);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -180,11 +180,11 @@ gst_d3d11_composition_overlay_new (GstD3D11OverlayCompositor * self,
|
|||
texture_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||
texture_desc.CPUAccessFlags = 0;
|
||||
|
||||
texture = gst_d3d11_device_create_texture (device,
|
||||
&texture_desc, &subresource_data);
|
||||
hr = ID3D11Device_CreateTexture2D (device_handle, &texture_desc,
|
||||
&subresource_data, &texture);
|
||||
gst_video_meta_unmap (vmeta, 0, &info);
|
||||
|
||||
if (!texture) {
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR ("Failed to create texture");
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -370,6 +370,39 @@ gst_d3d11_window_core_window_unprepare (GstD3D11Window * window)
|
|||
self->storage = NULL;
|
||||
}
|
||||
|
||||
static IDXGISwapChain1 *
|
||||
create_swap_chain_for_core_window (GstD3D11WindowCoreWindow * self,
|
||||
GstD3D11Device * device, guintptr core_window, DXGI_SWAP_CHAIN_DESC1 * desc,
|
||||
IDXGIOutput * output)
|
||||
{
|
||||
HRESULT hr;
|
||||
IDXGISwapChain1 *swap_chain = NULL;
|
||||
ID3D11Device *device_handle = gst_d3d11_device_get_device_handle (device);
|
||||
IDXGIFactory1 *factory = gst_d3d11_device_get_dxgi_factory_handle (device);
|
||||
IDXGIFactory2 *factory2 = NULL;
|
||||
|
||||
hr = factory->QueryInterface (IID_PPV_ARGS (&factory2));
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_WARNING_OBJECT (self, "IDXGIFactory2 interface is unavailable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_d3d11_device_lock (device);
|
||||
hr = factory2->CreateSwapChainForCoreWindow ((IUnknown *) device_handle,
|
||||
(IUnknown *) core_window, desc, output, &swap_chain);
|
||||
gst_d3d11_device_unlock (device);
|
||||
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_WARNING_OBJECT (self, "Cannot create SwapChain Object: 0x%x",
|
||||
(guint) hr);
|
||||
swap_chain = NULL;
|
||||
}
|
||||
|
||||
factory2->Release ();
|
||||
|
||||
return swap_chain;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_d3d11_window_core_window_create_swap_chain (GstD3D11Window * window,
|
||||
DXGI_FORMAT format, guint width, guint height, guint swapchain_flags,
|
||||
|
@ -395,7 +428,7 @@ gst_d3d11_window_core_window_create_swap_chain (GstD3D11Window * window,
|
|||
desc1.Flags = swapchain_flags;
|
||||
|
||||
new_swapchain =
|
||||
gst_d3d11_device_create_swap_chain_for_core_window (device,
|
||||
create_swap_chain_for_core_window (self, device,
|
||||
window->external_handle, &desc1, NULL);
|
||||
|
||||
if (!new_swapchain) {
|
||||
|
|
|
@ -344,6 +344,38 @@ gst_d3d11_window_swap_chain_panel_unprepare (GstD3D11Window * window)
|
|||
self->storage = NULL;
|
||||
}
|
||||
|
||||
static IDXGISwapChain1 *
|
||||
create_swap_chain_for_composition (GstD3D11WindowSwapChainPanel * self,
|
||||
GstD3D11Device * device, DXGI_SWAP_CHAIN_DESC1 * desc, IDXGIOutput * output)
|
||||
{
|
||||
HRESULT hr;
|
||||
IDXGISwapChain1 *swap_chain = NULL;
|
||||
ID3D11Device *device_handle = gst_d3d11_device_get_device_handle (device);
|
||||
IDXGIFactory1 *factory = gst_d3d11_device_get_dxgi_factory_handle (device);
|
||||
IDXGIFactory2 *factory2 = NULL;
|
||||
|
||||
hr = factory->QueryInterface (IID_PPV_ARGS (&factory2));
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_WARNING_OBJECT (self, "IDXGIFactory2 interface is unavailable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_d3d11_device_lock (device);
|
||||
hr = factory2->CreateSwapChainForComposition ((IUnknown *) device_handle,
|
||||
desc, output, &swap_chain);
|
||||
gst_d3d11_device_unlock (device);
|
||||
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_WARNING_OBJECT (self, "Cannot create SwapChain Object: 0x%x",
|
||||
(guint) hr);
|
||||
swap_chain = NULL;
|
||||
}
|
||||
|
||||
factory2->Release ();
|
||||
|
||||
return swap_chain;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_d3d11_window_swap_chain_panel_create_swap_chain (GstD3D11Window * window,
|
||||
DXGI_FORMAT format, guint width, guint height, guint swapchain_flags,
|
||||
|
@ -372,7 +404,7 @@ gst_d3d11_window_swap_chain_panel_create_swap_chain (GstD3D11Window * window,
|
|||
desc1.Flags = swapchain_flags;
|
||||
|
||||
new_swapchain =
|
||||
gst_d3d11_device_create_swap_chain_for_composition (device, &desc1, NULL);
|
||||
create_swap_chain_for_composition (self, device, &desc1, NULL);
|
||||
|
||||
if (!new_swapchain) {
|
||||
GST_ERROR_OBJECT (self, "Cannot create swapchain");
|
||||
|
|
|
@ -750,6 +750,65 @@ gst_d3d11_window_win32_disable_alt_enter (GstD3D11WindowWin32 * self,
|
|||
factory->Release ();
|
||||
}
|
||||
|
||||
static IDXGISwapChain *
|
||||
create_swap_chain (GstD3D11WindowWin32 * self, GstD3D11Device * device,
|
||||
DXGI_SWAP_CHAIN_DESC * desc)
|
||||
{
|
||||
HRESULT hr;
|
||||
IDXGISwapChain *swap_chain = NULL;
|
||||
ID3D11Device *device_handle = gst_d3d11_device_get_device_handle (device);
|
||||
IDXGIFactory1 *factory = gst_d3d11_device_get_dxgi_factory_handle (device);
|
||||
|
||||
gst_d3d11_device_lock (device);
|
||||
hr = factory->CreateSwapChain ((IUnknown *) device_handle,
|
||||
desc, &swap_chain);
|
||||
gst_d3d11_device_unlock (device);
|
||||
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_WARNING_OBJECT (self, "Cannot create SwapChain Object: 0x%x",
|
||||
(guint) hr);
|
||||
swap_chain = NULL;
|
||||
}
|
||||
|
||||
return swap_chain;
|
||||
}
|
||||
|
||||
#if (DXGI_HEADER_VERSION >= 2)
|
||||
static IDXGISwapChain1 *
|
||||
create_swap_chain_for_hwnd (GstD3D11WindowWin32 * self, GstD3D11Device * device,
|
||||
HWND hwnd, DXGI_SWAP_CHAIN_DESC1 * desc,
|
||||
DXGI_SWAP_CHAIN_FULLSCREEN_DESC * fullscreen_desc, IDXGIOutput * output)
|
||||
{
|
||||
HRESULT hr;
|
||||
IDXGISwapChain1 *swap_chain = NULL;
|
||||
ID3D11Device *device_handle = gst_d3d11_device_get_device_handle (device);
|
||||
IDXGIFactory1 *factory = gst_d3d11_device_get_dxgi_factory_handle (device);
|
||||
IDXGIFactory2 *factory2 = NULL;
|
||||
|
||||
hr = factory->QueryInterface (IID_PPV_ARGS (&factory2));
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_WARNING_OBJECT (self, "IDXGIFactory2 interface is unavailable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_d3d11_device_lock (device);
|
||||
hr = factory2->CreateSwapChainForHwnd (
|
||||
(IUnknown *) device_handle, hwnd, desc, fullscreen_desc,
|
||||
output, &swap_chain);
|
||||
gst_d3d11_device_unlock (device);
|
||||
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_WARNING_OBJECT (self, "Cannot create SwapChain Object: 0x%x",
|
||||
(guint) hr);
|
||||
swap_chain = NULL;
|
||||
}
|
||||
|
||||
factory2->Release ();
|
||||
|
||||
return swap_chain;
|
||||
}
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
gst_d3d11_window_win32_create_swap_chain (GstD3D11Window * window,
|
||||
DXGI_FORMAT format, guint width, guint height,
|
||||
|
@ -785,7 +844,7 @@ gst_d3d11_window_win32_create_swap_chain (GstD3D11Window * window,
|
|||
desc1.Flags = swapchain_flags;
|
||||
|
||||
new_swapchain = (IDXGISwapChain *)
|
||||
gst_d3d11_device_create_swap_chain_for_hwnd (device,
|
||||
create_swap_chain_for_hwnd (self, device,
|
||||
self->internal_hwnd, &desc1, NULL, NULL);
|
||||
|
||||
if (!new_swapchain) {
|
||||
|
@ -820,7 +879,7 @@ gst_d3d11_window_win32_create_swap_chain (GstD3D11Window * window,
|
|||
desc.Windowed = TRUE;
|
||||
desc.Flags = swapchain_flags;
|
||||
|
||||
new_swapchain = gst_d3d11_device_create_swap_chain (device, &desc);
|
||||
new_swapchain = create_swap_chain (self, device, &desc);
|
||||
}
|
||||
|
||||
if (!new_swapchain) {
|
||||
|
|
Loading…
Reference in a new issue