Commit d895ea98 authored by Steve Lhomme's avatar Steve Lhomme Committed by Jean-Baptiste Kempf

d3d_fmt: add a function to acquire the resources used in the picture_sys_t

This is the reverse of ReleasePictureSys
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent f4da1404
......@@ -231,6 +231,7 @@ static struct va_pic_context *CreatePicContext(vlc_va_surface_t *va_surface,
pic_ctx->picsys.resource[i] = p_resource;
pic_ctx->picsys.resourceView[i] = resourceView[i];
}
AcquirePictureSys(&pic_ctx->picsys);
pic_ctx->picsys.context = context;
done:
return pic_ctx;
......@@ -302,16 +303,6 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
directx_va_Release(va_surface);
return VLC_ENOMEM;
}
ID3D11VideoDecoderOutputView_AddRef(pic_ctx->picsys.decoder);
ID3D11DeviceContext_AddRef(pic_ctx->picsys.context);
for (int i=0; i<D3D11_MAX_SHADER_VIEW; i++)
{
if (pic_ctx->picsys.resource[i])
ID3D11Resource_AddRef(pic_ctx->picsys.resource[i]);
if (pic_ctx->picsys.resourceView[i])
ID3D11ShaderResourceView_AddRef(pic_ctx->picsys.resourceView[i]);
}
pic->context = &pic_ctx->s;
}
*data = (uint8_t*)((struct va_pic_context *)pic->context)->picsys.decoder;
......
......@@ -229,7 +229,7 @@ static struct picture_context_t *CreatePicContext(vlc_va_surface_t *va_surface)
pic_ctx->s.destroy = d3d9_pic_context_destroy;
pic_ctx->s.copy = d3d9_pic_context_copy;
pic_ctx->picsys.surface = va_surface->decoderSurface;
IDirect3DSurface9_AddRef(pic_ctx->picsys.surface);
AcquirePictureSys(&pic_ctx->picsys);
return &pic_ctx->s;
}
......
......@@ -62,6 +62,22 @@ struct va_pic_context
* (ie not DXGI_FORMAT_UNKNWON) */
#define KNOWN_DXGI_INDEX 0
static inline void AcquirePictureSys(picture_sys_t *p_sys)
{
for (int i=0; i<D3D11_MAX_SHADER_VIEW; i++) {
if (p_sys->resourceView[i])
ID3D11ShaderResourceView_AddRef(p_sys->resourceView[i]);
if (p_sys->texture[i])
ID3D11Texture2D_AddRef(p_sys->texture[i]);
}
if (p_sys->context)
ID3D11DeviceContext_AddRef(p_sys->context);
if (p_sys->decoder)
ID3D11VideoDecoderOutputView_AddRef(p_sys->decoder);
if (p_sys->processorInput)
ID3D11VideoProcessorInputView_AddRef(p_sys->processorInput);
}
static inline void ReleasePictureSys(picture_sys_t *p_sys)
{
for (int i=0; i<D3D11_MAX_SHADER_VIEW; i++) {
......
......@@ -41,6 +41,11 @@ struct va_pic_context
vlc_va_surface_t *va_surface;
};
static inline void AcquirePictureSys(picture_sys_t *p_sys)
{
IDirect3DSurface9_AddRef(p_sys->surface);
}
static inline void ReleasePictureSys(picture_sys_t *p_sys)
{
IDirect3DSurface9_Release(p_sys->surface);
......
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