panfrost: Allocate UBOs on the stack, not the heap
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 15 Jul 2019 18:30:35 +0000 (11:30 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 15 Jul 2019 23:12:55 +0000 (16:12 -0700)
Saves a call to calloc (the maximum size is small and known at
compile-time) and fixes a leak.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_screen.c
src/gallium/drivers/panfrost/pan_screen.h

index d8faaa39bc255f4f3a6f103b9bd093c3ca52feba..ed9b3dec529994a187d7c33a16b33227c788da3a 100644 (file)
@@ -1283,7 +1283,7 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
                 assert(ubo_count >= 1);
 
                 size_t sz = sizeof(struct mali_uniform_buffer_meta) * ubo_count;
-                struct mali_uniform_buffer_meta *ubos = calloc(sz, 1);
+                struct mali_uniform_buffer_meta ubos[PAN_MAX_CONST_BUFFERS];
 
                 /* Upload uniforms as a UBO */
                 ubos[0].size = MALI_POSITIVE((2 + uniform_count));
index ff67c0b14bce5fb7b1ca882cb8dabc6895c65d58..27ff0020915b55712d51c7c3100aa0daee70bf65 100644 (file)
@@ -258,7 +258,7 @@ panfrost_get_shader_param(struct pipe_screen *screen,
                 return 16 * 1024 * sizeof(float);
 
         case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
-                return 16;
+                return PAN_MAX_CONST_BUFFERS;
 
         case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED:
                 return 0;
index 3a0e544c1a639dc0cb4325cbdc6074be586a7680..a0c6e2df63d8b88573f2acb62f55f5997d974e31 100644 (file)
@@ -42,6 +42,9 @@ struct panfrost_context;
 struct panfrost_resource;
 struct panfrost_screen;
 
+/* Driver limits */
+#define PAN_MAX_CONST_BUFFERS 16
+
 /* Flags for allocated memory */
 
 /* This memory region is executable */