Commit 687cee5f authored by Steve Lhomme's avatar Steve Lhomme

d3d9_fmt: no need to keep the whole D3DPRESENT_PARAMETERS

We only need the BackBufferFormat
parent 4cd31c83
......@@ -83,7 +83,8 @@ HRESULT D3D9_CreateDevice(vlc_object_t *o, d3d9_handle_t *hd3d, HWND hwnd,
out->adapterId = AdapterToUse;
out->hwnd = hwnd;
/* TODO only create a device for the decoder dimensions */
if (D3D9_FillPresentationParameters(hd3d, source, out))
D3DPRESENT_PARAMETERS d3dpp;
if (D3D9_FillPresentationParameters(hd3d, source, out, &d3dpp))
{
msg_Err(o, "Could not presentation parameters");
return E_INVALIDARG;
......@@ -113,14 +114,15 @@ HRESULT D3D9_CreateDevice(vlc_object_t *o, d3d9_handle_t *hd3d, HWND hwnd,
hr = IDirect3D9Ex_CreateDeviceEx(hd3d->objex, AdapterToUse,
DeviceType, hwnd,
creationFlags,
&out->pp, NULL, &out->devex);
&d3dpp, NULL, &out->devex);
else
hr = IDirect3D9_CreateDevice(hd3d->obj, AdapterToUse,
DeviceType, hwnd,
creationFlags,
&out->pp, &out->dev);
&d3dpp, &out->dev);
if (SUCCEEDED(hr))
{
out->BufferFormat = d3dpp.BackBufferFormat;
out->owner = true;
return hr;
}
......@@ -147,11 +149,12 @@ HRESULT D3D9_CreateDeviceExternal(IDirect3DDevice9 *dev, d3d9_handle_t *hd3d, HW
hr = IDirect3D9_GetDeviceCaps(hd3d->obj, out->adapterId, params.DeviceType, &out->caps);
if (FAILED(hr))
return hr;
if (D3D9_FillPresentationParameters(hd3d, source, out))
{
return E_FAIL;
}
D3DDISPLAYMODE d3ddm;
hr = IDirect3D9_GetAdapterDisplayMode(hd3d->obj, out->adapterId, &d3ddm);
if (FAILED(hr))
return hr;
IDirect3DDevice9_AddRef(out->dev);
out->BufferFormat = d3ddm.Format;
return S_OK;
}
......@@ -169,7 +172,9 @@ void D3D9_ReleaseDevice(d3d9_device_t *d3d_dev)
* from the default adapter.
*/
int D3D9_FillPresentationParameters(d3d9_handle_t *hd3d,
const video_format_t *source, d3d9_device_t *out)
const video_format_t *source,
const d3d9_device_t *out,
D3DPRESENT_PARAMETERS *d3dpp)
{
/*
** Get the current desktop display mode, so we can set up a back
......@@ -181,7 +186,6 @@ int D3D9_FillPresentationParameters(d3d9_handle_t *hd3d,
return VLC_EGENERIC;
/* Set up the structure used to create the D3DDevice. */
D3DPRESENT_PARAMETERS *d3dpp = &out->pp;
ZeroMemory(d3dpp, sizeof(D3DPRESENT_PARAMETERS));
d3dpp->Flags = D3DPRESENTFLAG_VIDEO;
d3dpp->Windowed = TRUE;
......
......@@ -61,7 +61,7 @@ typedef struct
bool owner;
/* creation parameters */
D3DPRESENT_PARAMETERS pp;
D3DFORMAT BufferFormat;
UINT adapterId;
HWND hwnd;
D3DCAPS9 caps;
......@@ -97,6 +97,6 @@ int D3D9_CreateExternal(vlc_object_t *, d3d9_handle_t *, IDirect3DDevice9 *);
void D3D9_Destroy(d3d9_handle_t *);
int D3D9_FillPresentationParameters(d3d9_handle_t *, const video_format_t *, d3d9_device_t *);
int D3D9_FillPresentationParameters(d3d9_handle_t *, const video_format_t *, const d3d9_device_t *, D3DPRESENT_PARAMETERS *);
#endif /* VLC_VIDEOCHROMA_D3D9_FMT_H_ */
......@@ -653,7 +653,7 @@ static int Direct3D9CreateScene(vout_display_t *vd, const video_format_t *fmt)
height,
1,
D3DUSAGE_RENDERTARGET,
p_d3d9_dev->pp.BackBufferFormat,
p_d3d9_dev->BufferFormat,
D3DPOOL_DEFAULT,
&sys->sceneTexture,
NULL);
......@@ -917,7 +917,7 @@ static int Direct3D9CreateResources(vout_display_t *vd, video_format_t *fmt)
if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(sys->hd3d.obj,
D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
sys->d3d_dev.pp.BackBufferFormat,
sys->d3d_dev.BufferFormat,
D3DUSAGE_DYNAMIC,
D3DRTYPE_TEXTURE,
dfmt))) {
......@@ -952,7 +952,8 @@ static int Direct3D9Reset(vout_display_t *vd, video_format_t *fmtp)
vout_display_sys_t *sys = vd->sys;
d3d9_device_t *p_d3d9_dev = &sys->d3d_dev;
if (D3D9_FillPresentationParameters(&sys->hd3d, &vd->source, p_d3d9_dev))
D3DPRESENT_PARAMETERS d3dpp;
if (D3D9_FillPresentationParameters(&sys->hd3d, &vd->source, p_d3d9_dev, &d3dpp))
{
msg_Err(vd, "Could not presentation parameters to reset device");
return VLC_EGENERIC;
......@@ -964,14 +965,15 @@ static int Direct3D9Reset(vout_display_t *vd, video_format_t *fmtp)
/* */
HRESULT hr;
if (sys->hd3d.use_ex){
hr = IDirect3DDevice9Ex_ResetEx(p_d3d9_dev->devex, &p_d3d9_dev->pp, NULL);
hr = IDirect3DDevice9Ex_ResetEx(p_d3d9_dev->devex, &d3dpp, NULL);
} else {
hr = IDirect3DDevice9_Reset(p_d3d9_dev->dev, &p_d3d9_dev->pp);
hr = IDirect3DDevice9_Reset(p_d3d9_dev->dev, &d3dpp);
}
if (FAILED(hr)) {
msg_Err(vd, "IDirect3DDevice9_Reset failed! (hr=0x%lX)", hr);
return VLC_EGENERIC;
}
p_d3d9_dev->BufferFormat = d3dpp.BackBufferFormat;
/* re-create them */
if (Direct3D9CreateResources(vd, fmtp)) {
......@@ -1536,7 +1538,7 @@ static int Direct3D9Open(vout_display_t *vd, video_format_t *fmt,
/* Find the appropriate D3DFORMAT for the render chroma, the format will be the closest to
* the requested chroma which is usable by the hardware in an offscreen surface, as they
* typically support more formats than textures */
const d3d9_format_t *d3dfmt = Direct3DFindFormat(vd, fmt, p_d3d9_dev->pp.BackBufferFormat);
const d3d9_format_t *d3dfmt = Direct3DFindFormat(vd, fmt, p_d3d9_dev->BufferFormat);
if (!d3dfmt) {
msg_Err(vd, "surface pixel format is not supported.");
goto error;
......@@ -1644,7 +1646,7 @@ static bool LocalSwapchainSetupDevice( void **opaque, const libvlc_video_direct3
static bool LocalSwapchainUpdateOutput( void *opaque, const libvlc_video_direct3d_cfg_t *cfg, libvlc_video_output_cfg_t *out )
{
vout_display_t *vd = opaque;
out->surface_format = vd->sys->d3d_dev.pp.BackBufferFormat;
out->surface_format = vd->sys->d3d_dev.BufferFormat;
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment