From bf6591e948d95b73c5b8d10fa448ec87e9572b8e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 3 Jun 2013 20:59:31 -0700 Subject: [PATCH] dri/intel: Add explicit size parameter to intel_region_alloc_for_fd MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Instead of assuming that the size will be height * pitch, have the caller pass in the size explicitly. Signed-off-by: Keith Packard Reviewed-by: Jordan Justen Reviewed-by: Kristian Høgsberg --- src/mesa/drivers/dri/i915/intel_regions.c | 4 ++-- src/mesa/drivers/dri/i915/intel_regions.h | 2 +- src/mesa/drivers/dri/i915/intel_screen.c | 4 ++-- src/mesa/drivers/dri/i965/intel_regions.c | 4 ++-- src/mesa/drivers/dri/i965/intel_regions.h | 1 + src/mesa/drivers/dri/i965/intel_screen.c | 4 ++-- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/mesa/drivers/dri/i915/intel_regions.c b/src/mesa/drivers/dri/i915/intel_regions.c index 44f7030c712..9f5b89e80c2 100644 --- a/src/mesa/drivers/dri/i915/intel_regions.c +++ b/src/mesa/drivers/dri/i915/intel_regions.c @@ -209,6 +209,7 @@ struct intel_region * intel_region_alloc_for_fd(struct intel_screen *screen, GLuint cpp, GLuint width, GLuint height, GLuint pitch, + GLuint size, int fd, const char *name) { struct intel_region *region; @@ -216,8 +217,7 @@ intel_region_alloc_for_fd(struct intel_screen *screen, int ret; uint32_t bit_6_swizzle, tiling; - buffer = drm_intel_bo_gem_create_from_prime(screen->bufmgr, - fd, height * pitch); + buffer = drm_intel_bo_gem_create_from_prime(screen->bufmgr, fd, size); if (buffer == NULL) return NULL; ret = drm_intel_bo_get_tiling(buffer, &tiling, &bit_6_swizzle); diff --git a/src/mesa/drivers/dri/i915/intel_regions.h b/src/mesa/drivers/dri/i915/intel_regions.h index 5c612a925b9..6bc4a426a7e 100644 --- a/src/mesa/drivers/dri/i915/intel_regions.h +++ b/src/mesa/drivers/dri/i915/intel_regions.h @@ -91,7 +91,7 @@ struct intel_region * intel_region_alloc_for_fd(struct intel_screen *screen, GLuint cpp, GLuint width, GLuint height, GLuint pitch, - int fd, const char *name); + GLuint size, int fd, const char *name); bool intel_region_flink(struct intel_region *region, uint32_t *name); diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c index 7b73b80520c..d46d0eb19cb 100644 --- a/src/mesa/drivers/dri/i915/intel_screen.c +++ b/src/mesa/drivers/dri/i915/intel_screen.c @@ -654,8 +654,8 @@ intel_create_image_from_fds(__DRIscreen *screen, return NULL; image->region = intel_region_alloc_for_fd(intelScreen, - 1, width, height, - strides[0], fds[0], "image"); + f->planes[0].cpp, width, height, strides[0], + height * strides[0], fds[0], "image"); if (image->region == NULL) { free(image); return NULL; diff --git a/src/mesa/drivers/dri/i965/intel_regions.c b/src/mesa/drivers/dri/i965/intel_regions.c index a6b80fdbf81..3920f4f5482 100644 --- a/src/mesa/drivers/dri/i965/intel_regions.c +++ b/src/mesa/drivers/dri/i965/intel_regions.c @@ -209,6 +209,7 @@ struct intel_region * intel_region_alloc_for_fd(struct intel_screen *screen, GLuint cpp, GLuint width, GLuint height, GLuint pitch, + GLuint size, int fd, const char *name) { struct intel_region *region; @@ -216,8 +217,7 @@ intel_region_alloc_for_fd(struct intel_screen *screen, int ret; uint32_t bit_6_swizzle, tiling; - buffer = drm_intel_bo_gem_create_from_prime(screen->bufmgr, - fd, height * pitch); + buffer = drm_intel_bo_gem_create_from_prime(screen->bufmgr, fd, size); if (buffer == NULL) return NULL; ret = drm_intel_bo_get_tiling(buffer, &tiling, &bit_6_swizzle); diff --git a/src/mesa/drivers/dri/i965/intel_regions.h b/src/mesa/drivers/dri/i965/intel_regions.h index f08a113c936..05dfef36fe4 100644 --- a/src/mesa/drivers/dri/i965/intel_regions.h +++ b/src/mesa/drivers/dri/i965/intel_regions.h @@ -92,6 +92,7 @@ struct intel_region * intel_region_alloc_for_fd(struct intel_screen *screen, GLuint cpp, GLuint width, GLuint height, GLuint pitch, + GLuint size, int fd, const char *name); bool diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index a26a0b7d2f0..a319b9951a9 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -719,8 +719,8 @@ intel_create_image_from_fds(__DRIscreen *screen, return NULL; image->region = intel_region_alloc_for_fd(intelScreen, - 1, width, height, - strides[0], fds[0], "image"); + f->planes[0].cpp, width, height, strides[0], + height * strides[0], fds[0], "image"); if (image->region == NULL) { free(image); return NULL; -- 2.30.2