[vlc-commits] d3d11_fmt: always allocate on texture at a time

Steve Lhomme git at videolan.org
Tue Jul 28 16:30:10 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Jul 28 15:12:36 2020 +0200| [b047c95b2fe3c26f46bb12a91c8c820c72c98362] | committer: Steve Lhomme

d3d11_fmt: always allocate on texture at a time

We never use an array of texture anymore. Only the decoder needs it and doesn't
use this API.

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

 modules/hw/d3d11/d3d11_surface.c        |  2 +-
 modules/video_chroma/d3d11_fmt.c        | 22 ++++++++++------------
 modules/video_chroma/d3d11_fmt.h        |  4 ++--
 modules/video_output/win32/direct3d11.c |  4 ++--
 4 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/modules/hw/d3d11/d3d11_surface.c b/modules/hw/d3d11/d3d11_surface.c
index 4622436c4e..a5fc45ccf2 100644
--- a/modules/hw/d3d11/d3d11_surface.c
+++ b/modules/hw/d3d11/d3d11_surface.c
@@ -622,7 +622,7 @@ static picture_t *AllocateCPUtoGPUTexture(filter_t *p_filter, filter_sys_t *p_sy
     }
 
     if (AllocateTextures(p_filter, p_sys->d3d_dev, cfg,
-                         &p_dst->format, 1, pic_ctx->picsys.texture, p_dst->p) != VLC_SUCCESS)
+                         &p_dst->format, pic_ctx->picsys.texture, p_dst->p) != VLC_SUCCESS)
         goto done;
 
     if (unlikely(D3D11_AllocateResourceView(p_filter, p_sys->d3d_dev->d3ddevice, cfg,
diff --git a/modules/video_chroma/d3d11_fmt.c b/modules/video_chroma/d3d11_fmt.c
index 4f7d0c2954..6fc6021da0 100644
--- a/modules/video_chroma/d3d11_fmt.c
+++ b/modules/video_chroma/d3d11_fmt.c
@@ -737,7 +737,7 @@ const d3d_format_t *(FindD3D11Format)(vlc_object_t *o,
 #undef AllocateTextures
 int AllocateTextures( vlc_object_t *obj, d3d11_device_t *d3d_dev,
                       const d3d_format_t *cfg, const video_format_t *fmt,
-                      unsigned pool_size, ID3D11Texture2D *textures[],
+                      ID3D11Texture2D *textures[],
                       plane_t out_planes[] )
 {
     plane_t planes[PICTURE_PLANE_MAX];
@@ -750,6 +750,7 @@ int AllocateTextures( vlc_object_t *obj, d3d11_device_t *d3d_dev,
     texDesc.SampleDesc.Count = 1;
     texDesc.MiscFlags = 0; //D3D11_RESOURCE_MISC_SHARED;
     texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
+    texDesc.ArraySize = 1;
     if (is_d3d11_opaque(fmt->i_chroma)) {
         texDesc.BindFlags |= D3D11_BIND_DECODER;
         texDesc.Usage = D3D11_USAGE_DEFAULT;
@@ -758,7 +759,6 @@ int AllocateTextures( vlc_object_t *obj, d3d11_device_t *d3d_dev,
         texDesc.Usage = D3D11_USAGE_DYNAMIC;
         texDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
     }
-    texDesc.ArraySize = pool_size;
 
     const vlc_chroma_description_t *p_chroma_desc = vlc_fourcc_GetChromaDescription( fmt->i_chroma );
     if( !p_chroma_desc )
@@ -785,7 +785,7 @@ int AllocateTextures( vlc_object_t *obj, d3d11_device_t *d3d_dev,
 
         hr = ID3D11Device_CreateTexture2D( d3d_dev->d3ddevice, &texDesc, NULL, &slicedTexture );
         if (FAILED(hr)) {
-            msg_Err(obj, "CreateTexture2D failed for the %d pool. (hr=0x%lX)", pool_size, hr);
+            msg_Err(obj, "CreateTexture2D failed. (hr=0x%lX)", hr);
             goto error;
         }
     }
@@ -800,18 +800,17 @@ int AllocateTextures( vlc_object_t *obj, d3d11_device_t *d3d_dev,
         p->i_pixel_pitch   = p_chroma_desc->pixel_size;
     }
 
-    for (unsigned picture_count = 0; picture_count < pool_size; picture_count++) {
         for (plane = 0; plane < plane_count; plane++)
         {
             if (slicedTexture) {
-                textures[picture_count * D3D11_MAX_SHADER_VIEW + plane] = slicedTexture;
+                textures[plane] = slicedTexture;
                 ID3D11Texture2D_AddRef(slicedTexture);
             } else {
                 texDesc.Height = planes[plane].i_lines;
                 texDesc.Width  = planes[plane].i_pitch;
-                hr = ID3D11Device_CreateTexture2D( d3d_dev->d3ddevice, &texDesc, NULL, &textures[picture_count * D3D11_MAX_SHADER_VIEW + plane] );
+                hr = ID3D11Device_CreateTexture2D( d3d_dev->d3ddevice, &texDesc, NULL, &textures[plane] );
                 if (FAILED(hr)) {
-                    msg_Err(obj, "CreateTexture2D failed for the %d pool. (hr=0x%lX)", pool_size, hr);
+                    msg_Err(obj, "CreateTexture2D failed for plane %d. (hr=0x%lX)", plane, hr);
                     goto error;
                 }
             }
@@ -823,14 +822,13 @@ int AllocateTextures( vlc_object_t *obj, d3d11_device_t *d3d_dev,
             }
         for (; plane < D3D11_MAX_SHADER_VIEW; plane++) {
             if (!cfg->resourceFormat[plane])
-                textures[picture_count * D3D11_MAX_SHADER_VIEW + plane] = NULL;
+                textures[plane] = NULL;
             else
             {
-                textures[picture_count * D3D11_MAX_SHADER_VIEW + plane] = textures[picture_count * D3D11_MAX_SHADER_VIEW];
-                ID3D11Texture2D_AddRef(textures[picture_count * D3D11_MAX_SHADER_VIEW + plane]);
+                textures[plane] = textures[0];
+                ID3D11Texture2D_AddRef(textures[plane]);
             }
         }
-    }
 
     if (slicedTexture)
         ID3D11Texture2D_Release(slicedTexture);
@@ -910,7 +908,7 @@ picture_t *D3D11_AllocPicture(vlc_object_t *obj,
 
     d3d11_decoder_device_t *dev_sys = GetD3D11OpaqueContext(vctx_out);
     if (AllocateTextures(obj, &dev_sys->d3d_dev, cfg,
-                         fmt, 1, pic_ctx->picsys.texture, NULL) != VLC_SUCCESS)
+                         fmt, pic_ctx->picsys.texture, NULL) != VLC_SUCCESS)
     {
         picture_Release(pic);
         free(pic_ctx);
diff --git a/modules/video_chroma/d3d11_fmt.h b/modules/video_chroma/d3d11_fmt.h
index 946850cb31..137bf8b7ae 100644
--- a/modules/video_chroma/d3d11_fmt.h
+++ b/modules/video_chroma/d3d11_fmt.h
@@ -170,9 +170,9 @@ const d3d_format_t *FindD3D11Format(vlc_object_t *,
     FindD3D11Format(VLC_OBJECT(a),b,c,d,e,f,g,h,i)
 
 int AllocateTextures(vlc_object_t *, d3d11_device_t *, const d3d_format_t *,
-                     const video_format_t *, unsigned pool_size, ID3D11Texture2D *textures[],
+                     const video_format_t *, ID3D11Texture2D *textures[],
                      plane_t planes[]);
-#define AllocateTextures(a,b,c,d,e,f,g)  AllocateTextures(VLC_OBJECT(a),b,c,d,e,f,g)
+#define AllocateTextures(a,b,c,d,e,f)  AllocateTextures(VLC_OBJECT(a),b,c,d,e,f)
 
 static inline void d3d11_device_lock(d3d11_device_t *d3d_dev)
 {
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 6b3670ac3d..47eecf9582 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -1114,7 +1114,7 @@ static int Direct3D11CreateFormatResources(vout_display_t *vd, const video_forma
         if (!is_d3d11_opaque(fmt->i_chroma))
             texture_fmt.i_chroma = sys->picQuad.textureFormat->fourcc;
 
-        if (AllocateTextures(vd, sys->d3d_dev, sys->picQuad.textureFormat, &texture_fmt, 1, textures, sys->stagingPlanes))
+        if (AllocateTextures(vd, sys->d3d_dev, sys->picQuad.textureFormat, &texture_fmt, textures, sys->stagingPlanes))
         {
             msg_Err(vd, "Failed to allocate the staging texture");
             return VLC_EGENERIC;
@@ -1300,7 +1300,7 @@ static int Direct3D11MapSubpicture(vout_display_t *vd, int *subpicture_region_co
             if (unlikely(d3dquad==NULL)) {
                 continue;
             }
-            if (AllocateTextures(vd, sys->d3d_dev, sys->regionQuad.textureFormat, &r->p_picture->format, 1, d3dquad->picSys.texture, NULL)) {
+            if (AllocateTextures(vd, sys->d3d_dev, sys->regionQuad.textureFormat, &r->p_picture->format, d3dquad->picSys.texture, NULL)) {
                 msg_Err(vd, "Failed to allocate %dx%d texture for OSD",
                         r->fmt.i_visible_width, r->fmt.i_visible_height);
                 for (int j=0; j<D3D11_MAX_SHADER_VIEW; j++)



More information about the vlc-commits mailing list