Skip to content

Commit

Permalink
direct3d11: return early in UpdateStaging when not using the staging …
Browse files Browse the repository at this point in the history
…texture
  • Loading branch information
robUx4 committed Aug 22, 2024
1 parent ebb1740 commit 7bd96dc
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions modules/video_output/win32/direct3d11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,52 +380,52 @@ static int SetViewpoint(vout_display_t *vd, const vlc_viewpoint_t *viewpoint)
static int UpdateStaging(vout_display_t *vd, const video_format_t *fmt)
{
vout_display_sys_t *sys = static_cast<vout_display_sys_t *>(vd->sys);
if (sys->use_staging_texture)
if (!sys->use_staging_texture)
return VLC_SUCCESS;

/* we need a staging texture */
ID3D11Texture2D *textures[DXGI_MAX_SHADER_VIEW] = {0};
video_format_t texture_fmt = *vd->source;
texture_fmt.i_width = sys->picQuad.generic.i_width;
texture_fmt.i_height = sys->picQuad.generic.i_height;
if (!is_d3d11_opaque(fmt->i_chroma))
{
/* we need a staging texture */
ID3D11Texture2D *textures[DXGI_MAX_SHADER_VIEW] = {0};
video_format_t texture_fmt = *vd->source;
texture_fmt.i_width = sys->picQuad.generic.i_width;
texture_fmt.i_height = sys->picQuad.generic.i_height;
if (!is_d3d11_opaque(fmt->i_chroma))
{
texture_fmt.i_chroma = sys->picQuad.generic.textureFormat->fourcc;
}
texture_fmt.i_chroma = sys->picQuad.generic.textureFormat->fourcc;
}

if (AllocateTextures(vd, sys->d3d_dev, sys->picQuad.generic.textureFormat, &texture_fmt,
false, textures, sys->stagingPlanes))
{
msg_Err(vd, "Failed to allocate the staging texture");
return VLC_EGENERIC;
}
if (AllocateTextures(vd, sys->d3d_dev, sys->picQuad.generic.textureFormat, &texture_fmt,
false, textures, sys->stagingPlanes))
{
msg_Err(vd, "Failed to allocate the staging texture");
return VLC_EGENERIC;
}

if (D3D11_AllocateResourceView(vlc_object_logger(vd), sys->d3d_dev->d3ddevice, sys->picQuad.generic.textureFormat,
textures, 0, sys->stagingSys.renderSrc))
{
msg_Err(vd, "Failed to allocate the staging shader view");
return VLC_EGENERIC;
}
if (D3D11_AllocateResourceView(vlc_object_logger(vd), sys->d3d_dev->d3ddevice, sys->picQuad.generic.textureFormat,
textures, 0, sys->stagingSys.renderSrc))
{
msg_Err(vd, "Failed to allocate the staging shader view");
return VLC_EGENERIC;
}

for (unsigned plane = 0; plane < DXGI_MAX_SHADER_VIEW; plane++)
sys->stagingSys.texture[plane] = textures[plane];
for (unsigned plane = 0; plane < DXGI_MAX_SHADER_VIEW; plane++)
sys->stagingSys.texture[plane] = textures[plane];

if (sys->old_feature.processor)
if (sys->old_feature.processor)
{
HRESULT hr;
D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC outDesc;
outDesc.ViewDimension = D3D11_VPOV_DIMENSION_TEXTURE2D;
outDesc.Texture2D.MipSlice = 0;

hr = sys->old_feature.d3dviddev->CreateVideoProcessorOutputView(
textures[0],
sys->old_feature.enumerator.Get(),
&outDesc,
sys->old_feature.outputView.ReleaseAndGetAddressOf());
if (FAILED(hr))
{
HRESULT hr;
D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC outDesc;
outDesc.ViewDimension = D3D11_VPOV_DIMENSION_TEXTURE2D;
outDesc.Texture2D.MipSlice = 0;

hr = sys->old_feature.d3dviddev->CreateVideoProcessorOutputView(
textures[0],
sys->old_feature.enumerator.Get(),
&outDesc,
sys->old_feature.outputView.ReleaseAndGetAddressOf());
if (FAILED(hr))
{
msg_Dbg(vd,"Failed to create processor output. (hr=0x%lX)", hr);
return VLC_EGENERIC;
}
msg_Dbg(vd,"Failed to create processor output. (hr=0x%lX)", hr);
return VLC_EGENERIC;
}
}
return VLC_SUCCESS;
Expand Down

0 comments on commit 7bd96dc

Please sign in to comment.