[vlc-commits] d3d9_fmt: store the adapter capabilities in the d3d9_device_t

Steve Lhomme git at videolan.org
Wed Mar 4 16:06:36 CET 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Mar  2 15:37:02 2020 +0100| [162eeaa427dff5d0d2358ba88ecc2a7ffd567d1e] | committer: Steve Lhomme

d3d9_fmt: store the adapter capabilities in the d3d9_device_t

It depends on the adapter used, so it doesn't belong in the more generic
d3d9_handle_t.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=162eeaa427dff5d0d2358ba88ecc2a7ffd567d1e
---

 modules/video_chroma/d3d9_fmt.c        |  8 ++++----
 modules/video_chroma/d3d9_fmt.h        |  3 ++-
 modules/video_output/win32/direct3d9.c | 27 ++++++++++++++-------------
 3 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/modules/video_chroma/d3d9_fmt.c b/modules/video_chroma/d3d9_fmt.c
index 2ae8ce8db8..0b3472367b 100644
--- a/modules/video_chroma/d3d9_fmt.c
+++ b/modules/video_chroma/d3d9_fmt.c
@@ -190,16 +190,16 @@ d3d9_handle_t *hd3d = &sys->dec_device.hd3d;
     /*
     ** Get device capabilities
     */
-    ZeroMemory(&hd3d->caps, sizeof(hd3d->caps));
-    hr = IDirect3D9_GetDeviceCaps(hd3d->obj, AdapterToUse, DeviceType, &hd3d->caps);
+    ZeroMemory(&out->caps, sizeof(out->caps));
+    hr = IDirect3D9_GetDeviceCaps(hd3d->obj, AdapterToUse, DeviceType, &out->caps);
     if (FAILED(hr)) {
        msg_Err(o, "Could not read adapter capabilities. (hr=0x%lX)", hr);
        goto error;
     }
-    msg_Dbg(o, "D3D9 device caps 0x%lX / 0x%lX", hd3d->caps.DevCaps, hd3d->caps.DevCaps2);
+    msg_Dbg(o, "D3D9 device caps 0x%lX / 0x%lX", out->caps.DevCaps, out->caps.DevCaps2);
 
     /* TODO: need to test device capabilities and select the right render function */
-    if (!(hd3d->caps.DevCaps2 & D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES)) {
+    if (!(out->caps.DevCaps2 & D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES)) {
         msg_Err(o, "Device does not support stretching from textures.");
         goto error;
     }
diff --git a/modules/video_chroma/d3d9_fmt.h b/modules/video_chroma/d3d9_fmt.h
index 362d3ae311..ddff8e0f2f 100644
--- a/modules/video_chroma/d3d9_fmt.h
+++ b/modules/video_chroma/d3d9_fmt.h
@@ -51,7 +51,6 @@ typedef struct
         IDirect3D9Ex        *objex;
     };
     bool                    use_ex;
-    D3DCAPS9                caps;
 } d3d9_handle_t;
 
 typedef struct
@@ -66,6 +65,8 @@ typedef struct
     /* creation parameters */
     D3DFORMAT               BufferFormat;
     UINT                    adapterId;
+
+    D3DCAPS9                caps;
 } d3d9_device_t;
 
 typedef struct
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 888cabcfc1..658bb81c9c 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -598,14 +598,14 @@ static int Direct3D9CreateScene(vout_display_t *vd, const video_format_t *fmt)
     IDirect3DDevice9_SetSamplerState(d3ddev, 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
 
     // Set linear filtering quality
-    if (sys->d3d9_device->hd3d.caps.TextureFilterCaps & D3DPTFILTERCAPS_MINFLINEAR) {
+    if (sys->d3d9_device->d3ddev.caps.TextureFilterCaps & D3DPTFILTERCAPS_MINFLINEAR) {
         //msg_Dbg(vd, "Using D3DTEXF_LINEAR for minification");
         IDirect3DDevice9_SetSamplerState(d3ddev, 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
     } else {
         //msg_Dbg(vd, "Using D3DTEXF_POINT for minification");
         IDirect3DDevice9_SetSamplerState(d3ddev, 0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
     }
-    if (sys->d3d9_device->hd3d.caps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFLINEAR) {
+    if (sys->d3d9_device->d3ddev.caps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFLINEAR) {
         //msg_Dbg(vd, "Using D3DTEXF_LINEAR for magnification");
         IDirect3DDevice9_SetSamplerState(d3ddev, 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
     } else {
@@ -636,7 +636,7 @@ static int Direct3D9CreateScene(vout_display_t *vd, const video_format_t *fmt)
     IDirect3DDevice9_SetRenderState(d3ddev, D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
     IDirect3DDevice9_SetRenderState(d3ddev, D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
 
-    if (sys->d3d9_device->hd3d.caps.AlphaCmpCaps & D3DPCMPCAPS_GREATER) {
+    if (sys->d3d9_device->d3ddev.caps.AlphaCmpCaps & D3DPCMPCAPS_GREATER) {
         IDirect3DDevice9_SetRenderState(d3ddev, D3DRS_ALPHATESTENABLE,TRUE);
         IDirect3DDevice9_SetRenderState(d3ddev, D3DRS_ALPHAREF, 0x00);
         IDirect3DDevice9_SetRenderState(d3ddev, D3DRS_ALPHAFUNC,D3DCMP_GREATER);
@@ -1506,7 +1506,8 @@ VLC_CONFIG_STRING_ENUM(FindShadersCallback)
 static bool LocalSwapchainUpdateOutput( void *opaque, const libvlc_video_render_cfg_t *cfg, libvlc_video_output_cfg_t *out )
 {
     vout_display_t *vd = opaque;
-    out->d3d9_format = vd->sys->d3d9_device->d3ddev.BufferFormat;
+    vout_display_sys_t *sys = vd->sys;
+    out->d3d9_format = sys->d3d9_device->d3ddev.BufferFormat;
     return true;
 }
 
@@ -1583,13 +1584,13 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
     }
 
 
-    if ( vd->source.i_visible_width  > sys->d3d9_device->hd3d.caps.MaxTextureWidth ||
-         vd->source.i_visible_height > sys->d3d9_device->hd3d.caps.MaxTextureHeight )
+    if ( vd->source.i_visible_width  > sys->d3d9_device->d3ddev.caps.MaxTextureWidth ||
+         vd->source.i_visible_height > sys->d3d9_device->d3ddev.caps.MaxTextureHeight )
     {
         msg_Err(vd, "Textures too large %ux%u max possible: %lx%lx",
                 vd->source.i_visible_width, vd->source.i_visible_height,
-                sys->d3d9_device->hd3d.caps.MaxTextureWidth,
-                sys->d3d9_device->hd3d.caps.MaxTextureHeight);
+                sys->d3d9_device->d3ddev.caps.MaxTextureWidth,
+                sys->d3d9_device->d3ddev.caps.MaxTextureHeight);
         goto error;
     }
 
@@ -1614,11 +1615,11 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
     /* Setup vout_display now that everything is fine */
     if (var_InheritBool(vd, "direct3d9-hw-blending") &&
         sys->d3dregion_format != D3DFMT_UNKNOWN &&
-        (sys->d3d9_device->hd3d.caps.SrcBlendCaps  & D3DPBLENDCAPS_SRCALPHA) &&
-        (sys->d3d9_device->hd3d.caps.DestBlendCaps & D3DPBLENDCAPS_INVSRCALPHA) &&
-        (sys->d3d9_device->hd3d.caps.TextureCaps   & D3DPTEXTURECAPS_ALPHA) &&
-        (sys->d3d9_device->hd3d.caps.TextureOpCaps & D3DTEXOPCAPS_SELECTARG1) &&
-        (sys->d3d9_device->hd3d.caps.TextureOpCaps & D3DTEXOPCAPS_MODULATE))
+        (sys->d3d9_device->d3ddev.caps.SrcBlendCaps  & D3DPBLENDCAPS_SRCALPHA) &&
+        (sys->d3d9_device->d3ddev.caps.DestBlendCaps & D3DPBLENDCAPS_INVSRCALPHA) &&
+        (sys->d3d9_device->d3ddev.caps.TextureCaps   & D3DPTEXTURECAPS_ALPHA) &&
+        (sys->d3d9_device->d3ddev.caps.TextureOpCaps & D3DTEXOPCAPS_SELECTARG1) &&
+        (sys->d3d9_device->d3ddev.caps.TextureOpCaps & D3DTEXOPCAPS_MODULATE))
         vd->info.subpicture_chromas = d3d_subpicture_chromas;
     else
         vd->info.subpicture_chromas = NULL;



More information about the vlc-commits mailing list