[PATCH] renderonly: fix dumb BO allocation for non 32bpp formats

Lucas Stach l.stach at pengutronix.de
Tue Jan 30 14:22:17 UTC 2018


Take into account the resource format, instead of applying a hardcoded
32bpp. This not only over-allocates 16bpp formats, but also results in
a wrong stride being filled into the handle.

Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
---
 src/gallium/auxiliary/renderonly/renderonly.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/renderonly/renderonly.c b/src/gallium/auxiliary/renderonly/renderonly.c
index da91f12b2ea1..8112b1563723 100644
--- a/src/gallium/auxiliary/renderonly/renderonly.c
+++ b/src/gallium/auxiliary/renderonly/renderonly.c
@@ -33,6 +33,7 @@
 
 #include "state_tracker/drm_driver.h"
 #include "pipe/p_screen.h"
+#include "util/u_format.h"
 #include "util/u_inlines.h"
 #include "util/u_memory.h"
 
@@ -73,7 +74,7 @@ renderonly_create_kms_dumb_buffer_for_resource(struct pipe_resource *rsc,
    struct drm_mode_create_dumb create_dumb = {
       .width = rsc->width0,
       .height = rsc->height0,
-      .bpp = 32,
+      .bpp = util_format_get_blocksize(rsc->format) * 8,
    };
    struct drm_mode_destroy_dumb destroy_dumb = { };
 
-- 
2.15.1



More information about the etnaviv mailing list