Mesa (main): d3d12: Don't use VLAs

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed May 18 16:37:13 UTC 2022


Module: Mesa
Branch: main
Commit: 4b34869d9d26514a3305394e598dafaf12a42cfb
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4b34869d9d26514a3305394e598dafaf12a42cfb

Author: Jesse Natalie <jenatali at microsoft.com>
Date:   Wed May 18 09:13:14 2022 -0700

d3d12: Don't use VLAs

Fixes: 739283da ("d3d12: Improve planar resource support to handle video requirements")
Reviewed-by: Sil Vilerino <sivileri at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16588>

---

 src/gallium/drivers/d3d12/d3d12_resource.cpp | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/d3d12/d3d12_resource.cpp b/src/gallium/drivers/d3d12/d3d12_resource.cpp
index 4b6ba78b29e..e3f247669de 100644
--- a/src/gallium/drivers/d3d12/d3d12_resource.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_resource.cpp
@@ -722,6 +722,8 @@ void d3d12_resource_get_planes_info(pipe_resource *pres,
    }
 }
 
+static constexpr unsigned d3d12_max_planes = 3;
+
 /**
  * Get stride and offset for the given pipe resource without the need to get
  * a winsys_handle.
@@ -736,10 +738,10 @@ d3d12_resource_get_info(struct pipe_screen *pscreen,
    struct d3d12_resource* res = d3d12_resource(pres);
    unsigned num_planes = util_format_get_num_planes(res->overall_format);
 
-   pipe_resource* planes[num_planes];
-   unsigned int strides[num_planes];
-   unsigned int layer_strides[num_planes];
-   unsigned int offsets[num_planes];
+   pipe_resource *planes[d3d12_max_planes];
+   unsigned int strides[d3d12_max_planes];
+   unsigned int layer_strides[d3d12_max_planes];
+   unsigned int offsets[d3d12_max_planes];
    unsigned staging_res_size = 0;
    d3d12_resource_get_planes_info(
       pres,
@@ -1444,10 +1446,10 @@ d3d12_transfer_map(struct pipe_context *pctx,
       /* Get planes information*/
 
       unsigned num_planes = util_format_get_num_planes(res->overall_format);
-      pipe_resource* planes[num_planes];
-      unsigned int strides[num_planes];
-      unsigned int layer_strides[num_planes];
-      unsigned int offsets[num_planes];
+      pipe_resource *planes[d3d12_max_planes];
+      unsigned int strides[d3d12_max_planes];
+      unsigned int layer_strides[d3d12_max_planes];
+      unsigned int offsets[d3d12_max_planes];
       unsigned staging_res_size = 0;
 
       d3d12_resource_get_planes_info(
@@ -1597,10 +1599,10 @@ d3d12_transfer_unmap(struct pipe_context *pctx,
 
          /* Get planes information*/
          unsigned num_planes = util_format_get_num_planes(res->overall_format);
-         pipe_resource* planes[num_planes];
-         unsigned int strides[num_planes];
-         unsigned int layer_strides[num_planes];
-         unsigned int offsets[num_planes];
+         pipe_resource *planes[d3d12_max_planes];
+         unsigned int strides[d3d12_max_planes];
+         unsigned int layer_strides[d3d12_max_planes];
+         unsigned int offsets[d3d12_max_planes];
          unsigned staging_res_size = 0;
 
          d3d12_resource_get_planes_info(



More information about the mesa-commit mailing list