dri/intel: Add explicit size parameter to intel_region_alloc_for_fd
Instead of assuming that the size will be height * pitch, have the caller pass in the size explicitly. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
This commit is contained in:

committed by
Eric Anholt

parent
888533dcd6
commit
bf6591e948
@@ -209,6 +209,7 @@ struct intel_region *
|
|||||||
intel_region_alloc_for_fd(struct intel_screen *screen,
|
intel_region_alloc_for_fd(struct intel_screen *screen,
|
||||||
GLuint cpp,
|
GLuint cpp,
|
||||||
GLuint width, GLuint height, GLuint pitch,
|
GLuint width, GLuint height, GLuint pitch,
|
||||||
|
GLuint size,
|
||||||
int fd, const char *name)
|
int fd, const char *name)
|
||||||
{
|
{
|
||||||
struct intel_region *region;
|
struct intel_region *region;
|
||||||
@@ -216,8 +217,7 @@ intel_region_alloc_for_fd(struct intel_screen *screen,
|
|||||||
int ret;
|
int ret;
|
||||||
uint32_t bit_6_swizzle, tiling;
|
uint32_t bit_6_swizzle, tiling;
|
||||||
|
|
||||||
buffer = drm_intel_bo_gem_create_from_prime(screen->bufmgr,
|
buffer = drm_intel_bo_gem_create_from_prime(screen->bufmgr, fd, size);
|
||||||
fd, height * pitch);
|
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
ret = drm_intel_bo_get_tiling(buffer, &tiling, &bit_6_swizzle);
|
ret = drm_intel_bo_get_tiling(buffer, &tiling, &bit_6_swizzle);
|
||||||
|
@@ -91,7 +91,7 @@ struct intel_region *
|
|||||||
intel_region_alloc_for_fd(struct intel_screen *screen,
|
intel_region_alloc_for_fd(struct intel_screen *screen,
|
||||||
GLuint cpp,
|
GLuint cpp,
|
||||||
GLuint width, GLuint height, GLuint pitch,
|
GLuint width, GLuint height, GLuint pitch,
|
||||||
int fd, const char *name);
|
GLuint size, int fd, const char *name);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
intel_region_flink(struct intel_region *region, uint32_t *name);
|
intel_region_flink(struct intel_region *region, uint32_t *name);
|
||||||
|
@@ -654,8 +654,8 @@ intel_create_image_from_fds(__DRIscreen *screen,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
image->region = intel_region_alloc_for_fd(intelScreen,
|
image->region = intel_region_alloc_for_fd(intelScreen,
|
||||||
1, width, height,
|
f->planes[0].cpp, width, height, strides[0],
|
||||||
strides[0], fds[0], "image");
|
height * strides[0], fds[0], "image");
|
||||||
if (image->region == NULL) {
|
if (image->region == NULL) {
|
||||||
free(image);
|
free(image);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@@ -209,6 +209,7 @@ struct intel_region *
|
|||||||
intel_region_alloc_for_fd(struct intel_screen *screen,
|
intel_region_alloc_for_fd(struct intel_screen *screen,
|
||||||
GLuint cpp,
|
GLuint cpp,
|
||||||
GLuint width, GLuint height, GLuint pitch,
|
GLuint width, GLuint height, GLuint pitch,
|
||||||
|
GLuint size,
|
||||||
int fd, const char *name)
|
int fd, const char *name)
|
||||||
{
|
{
|
||||||
struct intel_region *region;
|
struct intel_region *region;
|
||||||
@@ -216,8 +217,7 @@ intel_region_alloc_for_fd(struct intel_screen *screen,
|
|||||||
int ret;
|
int ret;
|
||||||
uint32_t bit_6_swizzle, tiling;
|
uint32_t bit_6_swizzle, tiling;
|
||||||
|
|
||||||
buffer = drm_intel_bo_gem_create_from_prime(screen->bufmgr,
|
buffer = drm_intel_bo_gem_create_from_prime(screen->bufmgr, fd, size);
|
||||||
fd, height * pitch);
|
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
ret = drm_intel_bo_get_tiling(buffer, &tiling, &bit_6_swizzle);
|
ret = drm_intel_bo_get_tiling(buffer, &tiling, &bit_6_swizzle);
|
||||||
|
@@ -92,6 +92,7 @@ struct intel_region *
|
|||||||
intel_region_alloc_for_fd(struct intel_screen *screen,
|
intel_region_alloc_for_fd(struct intel_screen *screen,
|
||||||
GLuint cpp,
|
GLuint cpp,
|
||||||
GLuint width, GLuint height, GLuint pitch,
|
GLuint width, GLuint height, GLuint pitch,
|
||||||
|
GLuint size,
|
||||||
int fd, const char *name);
|
int fd, const char *name);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@@ -719,8 +719,8 @@ intel_create_image_from_fds(__DRIscreen *screen,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
image->region = intel_region_alloc_for_fd(intelScreen,
|
image->region = intel_region_alloc_for_fd(intelScreen,
|
||||||
1, width, height,
|
f->planes[0].cpp, width, height, strides[0],
|
||||||
strides[0], fds[0], "image");
|
height * strides[0], fds[0], "image");
|
||||||
if (image->region == NULL) {
|
if (image->region == NULL) {
|
||||||
free(image);
|
free(image);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Reference in New Issue
Block a user