"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "modules/video_output/win32/direct3d11.c" between
vlc-3.0.14.tar.xz and vlc-3.0.15.tar.xz

About: VLC (VideoLAN Client) is a multimedia player for various audio and video formats (MPEG-1/2/4, DivX, MP3, Vorbis, Ogg, ...) as well as DVDs, Audio CDs, VCDs, and various streaming protocols.

direct3d11.c  (vlc-3.0.14.tar.xz):direct3d11.c  (vlc-3.0.15.tar.xz)
skipping to change at line 95 skipping to change at line 95
set_capability("vout display", 300) set_capability("vout display", 300)
add_shortcut("direct3d11") add_shortcut("direct3d11")
set_callbacks(Open, Close) set_callbacks(Open, Close)
vlc_module_end () vlc_module_end ()
struct vout_display_sys_t struct vout_display_sys_t
{ {
vout_display_sys_win32_t sys; vout_display_sys_win32_t sys;
int log_level;
display_info_t display; display_info_t display;
HINSTANCE hdxgi_dll; /* handle of the opened dxgi dll */ HINSTANCE hdxgi_dll; /* handle of the opened dxgi dll */
d3d11_handle_t hd3d; d3d11_handle_t hd3d;
IDXGISwapChain1 *dxgiswapChain; /* DXGI 1.2 swap chain */ IDXGISwapChain1 *dxgiswapChain; /* DXGI 1.2 swap chain */
IDXGISwapChain4 *dxgiswapChain4; /* DXGI 1.5 for HDR */ IDXGISwapChain4 *dxgiswapChain4; /* DXGI 1.5 for HDR */
d3d11_device_t d3d_dev; d3d11_device_t d3d_dev;
d3d_quad_t picQuad; d3d_quad_t picQuad;
ID3D11Asynchronous *prepareWait;
#ifdef HAVE_D3D11_4_H #ifdef HAVE_D3D11_4_H
ID3D11Fence *d3dRenderFence; ID3D11Fence *d3dRenderFence;
ID3D11DeviceContext4 *d3dcontext4; ID3D11DeviceContext4 *d3dcontext4;
UINT64 renderFence; UINT64 renderFence;
HANDLE renderFinished; HANDLE renderFinished;
#endif #endif
picture_sys_t stagingSys; picture_sys_t stagingSys;
ID3D11RenderTargetView *d3drenderTargetView; ID3D11RenderTargetView *d3drenderTargetView;
skipping to change at line 1008 skipping to change at line 1009
{ {
d3d_quad_t *quad = (d3d_quad_t *) sys->d3dregions[i]->p_sys; d3d_quad_t *quad = (d3d_quad_t *) sys->d3dregions[i]->p_sys;
D3D11_RenderQuad(&sys->d3d_dev, quad, quad->picSys.resourceView, sys->d3drenderTargetView); D3D11_RenderQuad(&sys->d3d_dev, quad, quad->picSys.resourceView, sys->d3drenderTargetView);
} }
} }
} }
#ifdef HAVE_D3D11_4_H #ifdef HAVE_D3D11_4_H
if (sys->d3dcontext4) if (sys->d3dcontext4)
{ {
mtime_t render_start;
if (sys->log_level >= 4)
render_start = mdate();
if (sys->renderFence == UINT64_MAX) if (sys->renderFence == UINT64_MAX)
sys->renderFence; sys->renderFence;
else else
sys->renderFence++; sys->renderFence++;
ResetEvent(sys->renderFinished); ResetEvent(sys->renderFinished);
ID3D11Fence_SetEventOnCompletion(sys->d3dRenderFence, sys->renderFence, sys->renderFinished); ID3D11Fence_SetEventOnCompletion(sys->d3dRenderFence, sys->renderFence, sys->renderFinished);
ID3D11DeviceContext4_Signal(sys->d3dcontext4, sys->d3dRenderFence, sys-> renderFence); ID3D11DeviceContext4_Signal(sys->d3dcontext4, sys->d3dRenderFence, sys-> renderFence);
WaitForSingleObject(sys->renderFinished, INFINITE); WaitForSingleObject(sys->renderFinished, INFINITE);
if (sys->log_level >= 4)
msg_Dbg(vd, "waited %" PRId64 " ms for the render fence",
(mdate() - render_start) * 1000 / CLOCK_FREQ);
} }
else
#endif #endif
if (sys->prepareWait)
{
ID3D11DeviceContext_End(sys->d3d_dev.d3dcontext, sys->prepareWait);
while (S_FALSE == ID3D11DeviceContext_GetData(sys->d3d_dev.d3dcontext,
sys->prepareWait, NULL, 0,
0))
{
mtime_t sleep_duration = (picture->date - mdate()) / 4;
if (sleep_duration <= 2 * CLOCK_FREQ / 1000)
{
// don't wait any longer, the display will likely be late
// we'll finish waiting during the Display call
break;
}
// wait a little until the rendering is done
SleepEx(sleep_duration * 1000 / CLOCK_FREQ, TRUE);
}
}
if (is_d3d11_opaque(picture->format.i_chroma)) if (is_d3d11_opaque(picture->format.i_chroma))
d3d11_device_unlock( &sys->d3d_dev ); d3d11_device_unlock( &sys->d3d_dev );
} }
static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpic ture) static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpic ture)
{ {
vout_display_sys_t *sys = vd->sys; vout_display_sys_t *sys = vd->sys;
DXGI_PRESENT_PARAMETERS presentParams; DXGI_PRESENT_PARAMETERS presentParams;
memset(&presentParams, 0, sizeof(presentParams)); memset(&presentParams, 0, sizeof(presentParams));
d3d11_device_lock( &sys->d3d_dev ); d3d11_device_lock( &sys->d3d_dev );
HRESULT hr = IDXGISwapChain1_Present1(sys->dxgiswapChain, 0, 0, &presentPara ms); HRESULT hr = IDXGISwapChain1_Present1(sys->dxgiswapChain, 0, 0, &presentPara ms);
if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET)
{ {
/* TODO device lost */ /* TODO device lost */
msg_Err(vd, "SwapChain Present failed. (hr=0x%lX)", hr); msg_Err(vd, "SwapChain Present failed. (hr=0x%lX)", hr);
} }
if (sys->prepareWait)
{
mtime_t start = 0;
while (S_FALSE == ID3D11DeviceContext_GetData(sys->d3d_dev.d3dcontext,
sys->prepareWait, NULL, 0,
0))
{
if (start == 0)
start = mdate();
SleepEx(2, TRUE);
}
if (start != 0 && var_InheritInteger(vd, "verbose") >= 4)
msg_Dbg(vd, "rendering wasn't finished, waited extra %lld ms",
(mdate() - start) * 1000 / CLOCK_FREQ);
}
d3d11_device_unlock( &sys->d3d_dev ); d3d11_device_unlock( &sys->d3d_dev );
picture_Release(picture); picture_Release(picture);
if (subpicture) if (subpicture)
subpicture_Delete(subpicture); subpicture_Delete(subpicture);
CommonDisplay(vd); CommonDisplay(vd);
} }
static void Direct3D11Destroy(vout_display_t *vd) static void Direct3D11Destroy(vout_display_t *vd)
skipping to change at line 1377 skipping to change at line 1350
} }
if (Direct3D11CreateGenericResources(vd)) { if (Direct3D11CreateGenericResources(vd)) {
msg_Err(vd, "Failed to allocate resources"); msg_Err(vd, "Failed to allocate resources");
return VLC_EGENERIC; return VLC_EGENERIC;
} }
video_format_Clean(&vd->fmt); video_format_Clean(&vd->fmt);
vd->fmt = fmt; vd->fmt = fmt;
sys->log_level = var_InheritInteger(vd, "verbose");
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static int SetupOutputFormat(vout_display_t *vd, video_format_t *fmt) static int SetupOutputFormat(vout_display_t *vd, video_format_t *fmt)
{ {
vout_display_sys_t *sys = vd->sys; vout_display_sys_t *sys = vd->sys;
// look for the requested pixel format first // look for the requested pixel format first
sys->picQuad.formatInfo = GetDirectRenderingFormat(vd, fmt->i_chroma); sys->picQuad.formatInfo = GetDirectRenderingFormat(vd, fmt->i_chroma);
skipping to change at line 1690 skipping to change at line 1665
{ {
vout_display_sys_t *sys = vd->sys; vout_display_sys_t *sys = vd->sys;
HRESULT hr; HRESULT hr;
#ifdef HAVE_D3D11_4_H #ifdef HAVE_D3D11_4_H
hr = InitRenderFence(sys); hr = InitRenderFence(sys);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
msg_Dbg(vd, "using GPU render fence"); msg_Dbg(vd, "using GPU render fence");
} }
else
#endif #endif
{
D3D11_QUERY_DESC query = { 0 };
query.Query = D3D11_QUERY_EVENT;
hr = ID3D11Device_CreateQuery(sys->d3d_dev.d3ddevice, &query, (ID3D11Que
ry**)&sys->prepareWait);
}
ID3D11BlendState *pSpuBlendState; ID3D11BlendState *pSpuBlendState;
D3D11_BLEND_DESC spuBlendDesc = { 0 }; D3D11_BLEND_DESC spuBlendDesc = { 0 };
spuBlendDesc.RenderTarget[0].BlendEnable = TRUE; spuBlendDesc.RenderTarget[0].BlendEnable = TRUE;
spuBlendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA; spuBlendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
spuBlendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; spuBlendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
spuBlendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; spuBlendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
spuBlendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; spuBlendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
spuBlendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; spuBlendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
skipping to change at line 1910 skipping to change at line 1879
#ifdef HAVE_D3D11_4_H #ifdef HAVE_D3D11_4_H
if (sys->d3dcontext4) if (sys->d3dcontext4)
{ {
ID3D11Fence_Release(sys->d3dRenderFence); ID3D11Fence_Release(sys->d3dRenderFence);
sys->d3dRenderFence = NULL; sys->d3dRenderFence = NULL;
ID3D11DeviceContext4_Release(sys->d3dcontext4); ID3D11DeviceContext4_Release(sys->d3dcontext4);
sys->d3dcontext4 = NULL; sys->d3dcontext4 = NULL;
CloseHandle(sys->renderFinished); CloseHandle(sys->renderFinished);
sys->renderFinished = NULL; sys->renderFinished = NULL;
} }
else
#endif #endif
if (sys->prepareWait)
{
ID3D11Query_Release(sys->prepareWait);
sys->prepareWait = NULL;
}
msg_Dbg(vd, "Direct3D11 resources destroyed"); msg_Dbg(vd, "Direct3D11 resources destroyed");
} }
static void Direct3D11DeleteRegions(int count, picture_t **region) static void Direct3D11DeleteRegions(int count, picture_t **region)
{ {
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
if (region[i]) { if (region[i]) {
picture_Release(region[i]); picture_Release(region[i]);
} }
 End of changes. 12 change blocks. 
50 lines changed or deleted 10 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)