v3d: Add static asserts for other packed packet sizes.
authorEric Anholt <eric@anholt.net>
Fri, 8 Jun 2018 15:31:58 +0000 (08:31 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 14 Jun 2018 23:52:25 +0000 (16:52 -0700)
src/gallium/drivers/v3d/v3dx_draw.c
src/gallium/drivers/v3d/v3dx_state.c

index 4d872b3..c89ebda 100644 (file)
@@ -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) {
index e48e0f3..26bd06e 100644 (file)
@@ -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