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

direct3d11: move AllocateShaderView() in d3d11_fmt.h

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent e787080f
......@@ -24,6 +24,7 @@
#define VLC_VIDEOCHROMA_D3D11_FMT_H_
#include <d3d11.h>
#include <assert.h>
#include "dxgi_fmt.h"
......@@ -78,4 +79,57 @@ static inline void ReleasePictureSys(picture_sys_t *p_sys)
}
}
/* map texture planes to resource views */
static inline int AllocateShaderView(vlc_object_t *obj, ID3D11Device *d3ddevice,
const d3d_format_t *format,
ID3D11Texture2D *p_texture, UINT slice_index,
ID3D11ShaderResourceView *resourceView[D3D11_MAX_SHADER_VIEW])
{
HRESULT hr;
int i;
D3D11_SHADER_RESOURCE_VIEW_DESC resviewDesc = { 0 };
D3D11_TEXTURE2D_DESC texDesc;
ID3D11Texture2D_GetDesc(p_texture, &texDesc);
assert(texDesc.BindFlags & D3D11_BIND_SHADER_RESOURCE);
if (texDesc.ArraySize == 1)
{
resviewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
resviewDesc.Texture2D.MipLevels = 1;
}
else
{
resviewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
resviewDesc.Texture2DArray.MipLevels = -1;
resviewDesc.Texture2DArray.ArraySize = 1;
resviewDesc.Texture2DArray.FirstArraySlice = slice_index;
}
for (i=0; i<D3D11_MAX_SHADER_VIEW; i++)
{
resviewDesc.Format = format->resourceFormat[i];
if (resviewDesc.Format == DXGI_FORMAT_UNKNOWN)
resourceView[i] = NULL;
else
{
hr = ID3D11Device_CreateShaderResourceView(d3ddevice, (ID3D11Resource*)p_texture, &resviewDesc, &resourceView[i]);
if (FAILED(hr)) {
msg_Err(obj, "Could not Create the Texture ResourceView %d slice %d. (hr=0x%lX)", i, slice_index, hr);
break;
}
}
}
if (i != D3D11_MAX_SHADER_VIEW)
{
while (--i >= 0)
{
ID3D11ShaderResourceView_Release(resourceView[i]);
resourceView[i] = NULL;
}
return VLC_EGENERIC;
}
return VLC_SUCCESS;
}
#endif /* include-guard */
......@@ -574,59 +574,6 @@ static void Close(vlc_object_t *object)
free(vd->sys);
}
/* map texture planes to resource views */
static int AllocateShaderView(vlc_object_t *obj, ID3D11Device *d3ddevice,
const d3d_format_t *format,
ID3D11Texture2D *p_texture, UINT slice_index,
ID3D11ShaderResourceView *resourceView[D3D11_MAX_SHADER_VIEW])
{
HRESULT hr;
int i;
D3D11_SHADER_RESOURCE_VIEW_DESC resviewDesc = { 0 };
D3D11_TEXTURE2D_DESC texDesc;
ID3D11Texture2D_GetDesc(p_texture, &texDesc);
assert(texDesc.BindFlags & D3D11_BIND_SHADER_RESOURCE);
if (texDesc.ArraySize == 1)
{
resviewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
resviewDesc.Texture2D.MipLevels = 1;
}
else
{
resviewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
resviewDesc.Texture2DArray.MipLevels = -1;
resviewDesc.Texture2DArray.ArraySize = 1;
resviewDesc.Texture2DArray.FirstArraySlice = slice_index;
}
for (i=0; i<D3D11_MAX_SHADER_VIEW; i++)
{
resviewDesc.Format = format->resourceFormat[i];
if (resviewDesc.Format == DXGI_FORMAT_UNKNOWN)
resourceView[i] = NULL;
else
{
hr = ID3D11Device_CreateShaderResourceView(d3ddevice, (ID3D11Resource*)p_texture, &resviewDesc, &resourceView[i]);
if (FAILED(hr)) {
msg_Err(obj, "Could not Create the Texture ResourceView %d slice %d. (hr=0x%lX)", i, slice_index, hr);
break;
}
}
}
if (i != D3D11_MAX_SHADER_VIEW)
{
while (--i >= 0)
{
ID3D11ShaderResourceView_Release(resourceView[i]);
resourceView[i] = NULL;
}
return VLC_EGENERIC;
}
return VLC_SUCCESS;
}
static int AllocateTextures(vout_display_t *vd, const d3d_format_t *cfg,
video_format_t *fmt, unsigned pool_size,
ID3D11Texture2D *textures[],
......
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