[vlc-commits] [Git][videolan/vlc][master] 2 commits: d3d11_fmt: add a helper to find a hardware/software based d3d_format_t

Steve Lhomme (@robUx4) gitlab at videolan.org
Wed Apr 5 06:48:27 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
230fdf54 by Steve Lhomme at 2023-04-05T06:31:54+00:00
d3d11_fmt: add a helper to find a hardware/software based d3d_format_t

- - - - -
1b02bcda by Steve Lhomme at 2023-04-05T06:31:54+00:00
d3d11: use D3D11_RenderFormat to get render d3d_formats

- - - - -


9 changed files:

- modules/access/screen/dxgi.cpp
- modules/codec/avcodec/d3d11va.c
- modules/codec/mft.cpp
- modules/hw/d3d11/d3d11_decoder.cpp
- modules/hw/d3d11/d3d11_deinterlace.c
- modules/hw/d3d11/d3d11_filters.c
- modules/hw/d3d11/d3d11_surface.c
- modules/video_chroma/d3d11_fmt.h
- modules/video_output/win32/direct3d11.cpp


Changes:

=====================================
modules/access/screen/dxgi.cpp
=====================================
@@ -245,13 +245,7 @@ int screen_InitCaptureDXGI(demux_t *p_demux)
     DXGI_OUTDUPL_DESC outDesc;
     p_data->duplication->GetDesc(&outDesc);
 
-    for (p_data->output_format = DxgiGetRenderFormatList();
-         p_data->output_format->name != nullptr; ++p_data->output_format)
-    {
-        if (p_data->output_format->formatTexture == outDesc.ModeDesc.Format &&
-            is_d3d11_opaque(p_data->output_format->fourcc))
-            break;
-    }
+    p_data->output_format = D3D11_RenderFormat(outDesc.ModeDesc.Format ,true);
     if (unlikely(!p_data->output_format->name))
     {
         msg_Err(p_demux, "Unknown texture format %d", outDesc.ModeDesc.Format);


=====================================
modules/codec/avcodec/d3d11va.c
=====================================
@@ -369,20 +369,6 @@ static int DxGetInputList(vlc_va_t *va, input_list_t *p_list)
     return VLC_SUCCESS;
 }
 
-static const d3d_format_t *D3D11_FindDXGIFormat(DXGI_FORMAT dxgi)
-{
-    for (const d3d_format_t *output_format = DxgiGetRenderFormatList();
-         output_format->name != NULL; ++output_format)
-    {
-        if (output_format->formatTexture == dxgi &&
-                is_d3d11_opaque(output_format->fourcc))
-        {
-            return output_format;
-        }
-    }
-    return NULL;
-}
-
 static int DxSetupOutput(vlc_va_t *va, const directx_va_mode_t *mode, const video_format_t *fmt)
 {
     vlc_va_sys_t *sys = va->sys;
@@ -427,8 +413,8 @@ static int DxSetupOutput(vlc_va_t *va, const directx_va_mode_t *mode, const vide
     }
 
     if (decoder_format == NULL || decoder_format->formatTexture != DXGI_FORMAT_NV12)
-        processorInput[idx++] = D3D11_FindDXGIFormat(DXGI_FORMAT_NV12);
-    processorInput[idx++] = D3D11_FindDXGIFormat(DXGI_FORMAT_420_OPAQUE);
+        processorInput[idx++] = D3D11_RenderFormat(DXGI_FORMAT_NV12 ,true);
+    processorInput[idx++] = D3D11_RenderFormat(DXGI_FORMAT_420_OPAQUE ,true);
     processorInput[idx++] = NULL;
 
     /* */


=====================================
modules/codec/mft.cpp
=====================================
@@ -925,16 +925,7 @@ static int ProcessOutputStream(decoder_t *p_dec, DWORD stream_id, bool & keep_re
                             p_dec->fmt_out.video.i_width = desc.Width;
                             p_dec->fmt_out.video.i_height = desc.Height;
 
-                            for (const d3d_format_t *output_format = DxgiGetRenderFormatList();
-                                    output_format->name != NULL; ++output_format)
-                            {
-                                if (output_format->formatTexture == desc.Format &&
-                                    is_d3d11_opaque(output_format->fourcc))
-                                {
-                                    p_sys->cfg = output_format;
-                                    break;
-                                }
-                            }
+                            p_sys->cfg = D3D11_RenderFormat(desc.Format ,true);
 
                             p_dec->fmt_out.i_codec = p_sys->cfg->fourcc;
                             p_dec->fmt_out.video.i_chroma = p_sys->cfg->fourcc;


=====================================
modules/hw/d3d11/d3d11_decoder.cpp
=====================================
@@ -112,13 +112,7 @@ static int DecodeFrame( decoder_t *p_dec, block_t *p_block )
         D3D11_TEXTURE2D_DESC outDesc;
         src_sys->texture[0]->GetDesc(&outDesc);
 
-        for (p_sys->output_format = DxgiGetRenderFormatList();
-            p_sys->output_format->name != nullptr; ++p_sys->output_format)
-        {
-            if (p_sys->output_format->formatTexture == outDesc.Format &&
-                is_d3d11_opaque(p_sys->output_format->fourcc))
-                break;
-        }
+        p_sys->output_format = D3D11_RenderFormat(outDesc.Format ,true);
         if (unlikely(!p_sys->output_format->name))
         {
             msg_Err(p_dec, "Unknown texture format %d", outDesc.Format);


=====================================
modules/hw/d3d11/d3d11_deinterlace.c
=====================================
@@ -254,16 +254,7 @@ int D3D11OpenDeinterlace(filter_t *filter)
     d3d11_decoder_device_t *dev_sys = GetD3D11OpaqueContext( filter->vctx_in );
     sys->d3d_dev = &dev_sys->d3d_dev;
 
-    for (const d3d_format_t *output_format = DxgiGetRenderFormatList();
-            output_format->name != NULL; ++output_format)
-    {
-        if (output_format->formatTexture == vctx_sys->format &&
-            is_d3d11_opaque(output_format->fourcc))
-        {
-            sys->output_format = output_format;
-            break;
-        }
-    }
+    sys->output_format = D3D11_RenderFormat(vctx_sys->format ,true);
     if (unlikely(sys->output_format == NULL))
         goto error;
 


=====================================
modules/hw/d3d11/d3d11_filters.c
=====================================
@@ -188,17 +188,7 @@ static picture_t *AllocPicture( filter_t *p_filter )
 {
     d3d11_video_context_t *vctx_sys = GetD3D11ContextPrivate( p_filter->vctx_out );
 
-    const d3d_format_t *cfg = NULL;
-    for (const d3d_format_t *output_format = DxgiGetRenderFormatList();
-            output_format->name != NULL; ++output_format)
-    {
-        if (output_format->formatTexture == vctx_sys->format &&
-            is_d3d11_opaque(output_format->fourcc))
-        {
-            cfg = output_format;
-            break;
-        }
-    }
+    const d3d_format_t *cfg = D3D11_RenderFormat(vctx_sys->format ,true);
     if (unlikely(cfg == NULL))
         return NULL;
 


=====================================
modules/hw/d3d11/d3d11_surface.c
=====================================
@@ -613,17 +613,7 @@ static picture_t *AllocateCPUtoGPUTexture(filter_t *p_filter, filter_sys_t *p_sy
 
     d3d11_video_context_t *vctx_sys = GetD3D11ContextPrivate( p_filter->vctx_out );
 
-    const d3d_format_t *cfg = NULL;
-    for (const d3d_format_t *output_format = DxgiGetRenderFormatList();
-            output_format->name != NULL; ++output_format)
-    {
-        if (output_format->formatTexture == vctx_sys->format &&
-            !is_d3d11_opaque(output_format->fourcc))
-        {
-            cfg = output_format;
-            break;
-        }
-    }
+    const d3d_format_t *cfg = D3D11_RenderFormat(vctx_sys->format ,false);
     if (unlikely(cfg == NULL))
         return NULL;
 


=====================================
modules/video_chroma/d3d11_fmt.h
=====================================
@@ -151,6 +151,21 @@ void AcquireD3D11PictureSys(picture_sys_d3d11_t *p_sys);
 
 void ReleaseD3D11PictureSys(picture_sys_d3d11_t *p_sys);
 
+static inline const d3d_format_t *D3D11_RenderFormat(DXGI_FORMAT opaque, bool gpu_based)
+{
+    for (const d3d_format_t *output_format = DxgiGetRenderFormatList();
+            output_format->name != NULL; ++output_format)
+    {
+        if (output_format->formatTexture == opaque &&
+            is_d3d11_opaque(output_format->fourcc) == gpu_based)
+        {
+            return output_format;
+        }
+    }
+    return NULL;
+}
+
+
 /* map texture planes to resource views */
 int D3D11_AllocateResourceView(struct vlc_logger *obj, ID3D11Device *d3ddevice,
                              const d3d_format_t *format,


=====================================
modules/video_output/win32/direct3d11.cpp
=====================================
@@ -186,16 +186,7 @@ static int UpdateDisplayFormat(vout_display_t *vd, const video_format_t *fmt)
 
     display_info_t new_display = { };
 
-    for (const d3d_format_t *output_format = DxgiGetRenderFormatList();
-         output_format->name != NULL; ++output_format)
-    {
-        if (output_format->formatTexture == (DXGI_FORMAT)out.dxgi_format &&
-            !is_d3d11_opaque(output_format->fourcc))
-        {
-            new_display.pixelFormat = output_format;
-            break;
-        }
-    }
+    new_display.pixelFormat = D3D11_RenderFormat((DXGI_FORMAT)out.dxgi_format, false);
     if (unlikely(new_display.pixelFormat == NULL))
     {
         msg_Err(vd, "Could not find the output format.");
@@ -798,16 +789,7 @@ static int SetupOutputFormat(vout_display_t *vd, video_format_t *fmt, vlc_video_
     if (vtcx_sys != NULL &&
         D3D11_DeviceSupportsFormat( sys->d3d_dev, vtcx_sys->format, D3D11_FORMAT_SUPPORT_SHADER_LOAD ))
     {
-        for (const d3d_format_t *output_format = DxgiGetRenderFormatList();
-            output_format->name != NULL; ++output_format)
-        {
-            if (output_format->formatTexture == vtcx_sys->format &&
-                    is_d3d11_opaque(output_format->fourcc))
-            {
-                sys->picQuad.generic.textureFormat = output_format;
-                break;
-            }
-        }
+        sys->picQuad.generic.textureFormat = D3D11_RenderFormat(vtcx_sys->format ,true);
     }
 
     // look for the requested pixel format first



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/32705bd3675e8fb87eb3c5d827f91a5ae8d0bc3f...1b02bcdade10d023df77bafebc87d416de6ea674

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/32705bd3675e8fb87eb3c5d827f91a5ae8d0bc3f...1b02bcdade10d023df77bafebc87d416de6ea674
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list