Mesa (master): v3d: Add static asserts for other packed packet sizes.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 15 00:04:00 UTC 2018


Module: Mesa
Branch: master
Commit: 31548187cf761e27035f36e376da33c338458b2d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=31548187cf761e27035f36e376da33c338458b2d

Author: Eric Anholt <eric at anholt.net>
Date:   Fri Jun  8 08:31:58 2018 -0700

v3d: Add static asserts for other packed packet sizes.

---

 src/gallium/drivers/v3d/v3dx_draw.c  | 1 +
 src/gallium/drivers/v3d/v3dx_state.c | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/src/gallium/drivers/v3d/v3dx_draw.c b/src/gallium/drivers/v3d/v3dx_draw.c
index 4d872b30ec..c89ebda2aa 100644
--- a/src/gallium/drivers/v3d/v3dx_draw.c
+++ b/src/gallium/drivers/v3d/v3dx_draw.c
@@ -278,6 +278,7 @@ v3d_emit_gl_shader_state(struct v3d_context *v3d,
                         attr.maximum_index = 0xffffff;
 #endif
                 }
+                STATIC_ASSERT(sizeof(vtx->attrs) >= VC5_MAX_ATTRIBUTES * size);
         }
 
         if (vtx->num_elements == 0) {
diff --git a/src/gallium/drivers/v3d/v3dx_state.c b/src/gallium/drivers/v3d/v3dx_state.c
index e48e0f3767..26bd06e4df 100644
--- a/src/gallium/drivers/v3d/v3dx_state.c
+++ b/src/gallium/drivers/v3d/v3dx_state.c
@@ -194,6 +194,8 @@ v3d_create_depth_stencil_alpha_state(struct pipe_context *pctx,
         const struct pipe_stencil_state *back = &cso->stencil[1];
 
         if (front->enabled) {
+                STATIC_ASSERT(sizeof(so->stencil_front) >=
+                              cl_packet_length(STENCIL_CONFIG));
                 v3dx_pack(&so->stencil_front, STENCIL_CONFIG, config) {
                         config.front_config = true;
                         /* If !back->enabled, then the front values should be
@@ -214,6 +216,8 @@ v3d_create_depth_stencil_alpha_state(struct pipe_context *pctx,
                 }
         }
         if (back->enabled) {
+                STATIC_ASSERT(sizeof(so->stencil_back) >=
+                              cl_packet_length(STENCIL_CONFIG));
                 v3dx_pack(&so->stencil_back, STENCIL_CONFIG, config) {
                         config.front_config = false;
                         config.back_config = true;
@@ -699,6 +703,8 @@ v3d_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc,
 
         v3dx_pack(map, TEXTURE_SHADER_STATE, tex) {
 #else /* V3D_VERSION < 40 */
+        STATIC_ASSERT(sizeof(so->texture_shader_state) >=
+                      cl_packet_length(TEXTURE_SHADER_STATE));
         v3dx_pack(&so->texture_shader_state, TEXTURE_SHADER_STATE, tex) {
 #endif
 




More information about the mesa-commit mailing list