summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/v3d
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2018-11-01 12:15:25 -0700
committerEric Anholt <[email protected]>2018-11-01 13:54:36 -0700
commit47586ab56989bc4225caf173f5bb570f60c7759f (patch)
tree85b432590f8086f1ba8ae3bfe8ab0cd00a859ead /src/gallium/drivers/v3d
parent5313fb8abd2af8f0b5cfb8d3bc1b64697d8176d7 (diff)
v3d: Respect user-passed strides for BO imports.
If the caller has passed in a stride for (linear) BO import, we should use that stride when rendering to the BO (or, if we some day support texturing from linear-imported BOs, when doing the linear-to-UIF shadow copy). This lets us remove the extra stride-changing relayout in the simulator.
Diffstat (limited to 'src/gallium/drivers/v3d')
-rw-r--r--src/gallium/drivers/v3d/v3d_bufmgr.c13
-rw-r--r--src/gallium/drivers/v3d/v3d_bufmgr.h6
-rw-r--r--src/gallium/drivers/v3d/v3d_context.h3
-rw-r--r--src/gallium/drivers/v3d/v3d_resource.c17
-rw-r--r--src/gallium/drivers/v3d/v3d_simulator.c76
5 files changed, 19 insertions, 96 deletions
diff --git a/src/gallium/drivers/v3d/v3d_bufmgr.c b/src/gallium/drivers/v3d/v3d_bufmgr.c
index d01b60e3223..970c38e08fe 100644
--- a/src/gallium/drivers/v3d/v3d_bufmgr.c
+++ b/src/gallium/drivers/v3d/v3d_bufmgr.c
@@ -331,7 +331,6 @@ v3d_bo_last_unreference_locked_timed(struct v3d_bo *bo, time_t time)
static struct v3d_bo *
v3d_bo_open_handle(struct v3d_screen *screen,
- uint32_t winsys_stride,
uint32_t handle, uint32_t size)
{
struct v3d_bo *bo;
@@ -355,8 +354,7 @@ v3d_bo_open_handle(struct v3d_screen *screen,
bo->private = false;
#ifdef USE_V3D_SIMULATOR
- v3d_simulator_open_from_handle(screen->fd, winsys_stride,
- bo->handle, bo->size);
+ v3d_simulator_open_from_handle(screen->fd, bo->handle, bo->size);
bo->map = malloc(bo->size);
#endif
@@ -382,8 +380,7 @@ done:
}
struct v3d_bo *
-v3d_bo_open_name(struct v3d_screen *screen, uint32_t name,
- uint32_t winsys_stride)
+v3d_bo_open_name(struct v3d_screen *screen, uint32_t name)
{
struct drm_gem_open o = {
.name = name
@@ -395,11 +392,11 @@ v3d_bo_open_name(struct v3d_screen *screen, uint32_t name,
return NULL;
}
- return v3d_bo_open_handle(screen, winsys_stride, o.handle, o.size);
+ return v3d_bo_open_handle(screen, o.handle, o.size);
}
struct v3d_bo *
-v3d_bo_open_dmabuf(struct v3d_screen *screen, int fd, uint32_t winsys_stride)
+v3d_bo_open_dmabuf(struct v3d_screen *screen, int fd)
{
uint32_t handle;
int ret = drmPrimeFDToHandle(screen->fd, fd, &handle);
@@ -416,7 +413,7 @@ v3d_bo_open_dmabuf(struct v3d_screen *screen, int fd, uint32_t winsys_stride)
return NULL;
}
- return v3d_bo_open_handle(screen, winsys_stride, handle, size);
+ return v3d_bo_open_handle(screen, handle, size);
}
int
diff --git a/src/gallium/drivers/v3d/v3d_bufmgr.h b/src/gallium/drivers/v3d/v3d_bufmgr.h
index 8fbde5ae9af..48629c65356 100644
--- a/src/gallium/drivers/v3d/v3d_bufmgr.h
+++ b/src/gallium/drivers/v3d/v3d_bufmgr.h
@@ -60,10 +60,8 @@ struct v3d_bo *v3d_bo_alloc(struct v3d_screen *screen, uint32_t size,
const char *name);
void v3d_bo_last_unreference(struct v3d_bo *bo);
void v3d_bo_last_unreference_locked_timed(struct v3d_bo *bo, time_t time);
-struct v3d_bo *v3d_bo_open_name(struct v3d_screen *screen, uint32_t name,
- uint32_t winsys_stride);
-struct v3d_bo *v3d_bo_open_dmabuf(struct v3d_screen *screen, int fd,
- uint32_t winsys_stride);
+struct v3d_bo *v3d_bo_open_name(struct v3d_screen *screen, uint32_t name);
+struct v3d_bo *v3d_bo_open_dmabuf(struct v3d_screen *screen, int fd);
bool v3d_bo_flink(struct v3d_bo *bo, uint32_t *name);
int v3d_bo_get_dmabuf(struct v3d_bo *bo);
diff --git a/src/gallium/drivers/v3d/v3d_context.h b/src/gallium/drivers/v3d/v3d_context.h
index 70643e000b0..8e44bbae906 100644
--- a/src/gallium/drivers/v3d/v3d_context.h
+++ b/src/gallium/drivers/v3d/v3d_context.h
@@ -480,8 +480,7 @@ int v3d_simulator_flush(struct v3d_context *v3d,
struct drm_v3d_submit_cl *args,
struct v3d_job *job);
int v3d_simulator_ioctl(int fd, unsigned long request, void *arg);
-void v3d_simulator_open_from_handle(int fd, uint32_t winsys_stride,
- int handle, uint32_t size);
+void v3d_simulator_open_from_handle(int fd, int handle, uint32_t size);
static inline int
v3d_ioctl(int fd, unsigned long request, void *arg)
diff --git a/src/gallium/drivers/v3d/v3d_resource.c b/src/gallium/drivers/v3d/v3d_resource.c
index dd0db8cfd89..b9c578b9cf5 100644
--- a/src/gallium/drivers/v3d/v3d_resource.c
+++ b/src/gallium/drivers/v3d/v3d_resource.c
@@ -396,7 +396,7 @@ v3d_get_ub_pad(struct v3d_resource *rsc, uint32_t height)
}
static void
-v3d_setup_slices(struct v3d_resource *rsc)
+v3d_setup_slices(struct v3d_resource *rsc, uint32_t winsys_stride)
{
struct pipe_resource *prsc = &rsc->base;
uint32_t width = prsc->width0;
@@ -498,7 +498,10 @@ v3d_setup_slices(struct v3d_resource *rsc)
}
slice->offset = offset;
- slice->stride = level_width * rsc->cpp;
+ if (winsys_stride)
+ slice->stride = winsys_stride;
+ else
+ slice->stride = level_width * rsc->cpp;
slice->padded_height = level_height;
slice->size = level_height * slice->stride;
@@ -674,7 +677,7 @@ v3d_resource_create_with_modifiers(struct pipe_screen *pscreen,
rsc->internal_format = prsc->format;
- v3d_setup_slices(rsc);
+ v3d_setup_slices(rsc, 0);
if (!v3d_resource_bo_alloc(rsc))
goto fail;
@@ -730,12 +733,10 @@ v3d_resource_from_handle(struct pipe_screen *pscreen,
switch (whandle->type) {
case WINSYS_HANDLE_TYPE_SHARED:
- rsc->bo = v3d_bo_open_name(screen,
- whandle->handle, whandle->stride);
+ rsc->bo = v3d_bo_open_name(screen, whandle->handle);
break;
case WINSYS_HANDLE_TYPE_FD:
- rsc->bo = v3d_bo_open_dmabuf(screen,
- whandle->handle, whandle->stride);
+ rsc->bo = v3d_bo_open_dmabuf(screen, whandle->handle);
break;
default:
fprintf(stderr,
@@ -749,7 +750,7 @@ v3d_resource_from_handle(struct pipe_screen *pscreen,
rsc->internal_format = prsc->format;
- v3d_setup_slices(rsc);
+ v3d_setup_slices(rsc, whandle->stride);
v3d_debug_resource_layout(rsc, "import");
if (whandle->stride != slice->stride) {
diff --git a/src/gallium/drivers/v3d/v3d_simulator.c b/src/gallium/drivers/v3d/v3d_simulator.c
index e73cc6443a3..a9ff0f4a91c 100644
--- a/src/gallium/drivers/v3d/v3d_simulator.c
+++ b/src/gallium/drivers/v3d/v3d_simulator.c
@@ -104,9 +104,6 @@ struct v3d_simulator_bo {
uint32_t size;
void *vaddr;
- void *winsys_map;
- uint32_t winsys_stride;
-
int handle;
};
@@ -200,9 +197,6 @@ v3d_free_simulator_bo(struct v3d_simulator_bo *sim_bo)
{
struct v3d_simulator_file *sim_file = sim_bo->file;
- if (sim_bo->winsys_map)
- munmap(sim_bo->winsys_map, sim_bo->size);
-
set_gmp_flags(sim_file, sim_bo->block->ofs, sim_bo->size, 0x0);
mtx_lock(&sim_state.mutex);
@@ -274,30 +268,8 @@ v3d_simulator_flush(struct v3d_context *v3d,
struct v3d_screen *screen = v3d->screen;
int fd = screen->fd;
struct v3d_simulator_file *file = v3d_get_simulator_file_for_fd(fd);
- struct v3d_surface *csurf = v3d_surface(v3d->framebuffer.cbufs[0]);
- struct v3d_resource *ctex = csurf ? v3d_resource(csurf->base.texture) : NULL;
- struct v3d_simulator_bo *csim_bo = ctex ? v3d_get_simulator_bo(file, ctex->bo->handle) : NULL;
- uint32_t winsys_stride = ctex ? csim_bo->winsys_stride : 0;
- uint32_t sim_stride = ctex ? ctex->slices[0].stride : 0;
- uint32_t row_len = MIN2(sim_stride, winsys_stride);
int ret;
- if (ctex && csim_bo->winsys_map) {
-#if 0
- fprintf(stderr, "%dx%d %d %d %d\n",
- ctex->base.b.width0, ctex->base.b.height0,
- winsys_stride,
- sim_stride,
- ctex->bo->size);
-#endif
-
- for (int y = 0; y < ctex->base.height0; y++) {
- memcpy(ctex->bo->map + y * sim_stride,
- csim_bo->winsys_map + y * winsys_stride,
- row_len);
- }
- }
-
ret = v3d_simulator_pin_bos(fd, job);
if (ret)
return ret;
@@ -311,63 +283,19 @@ v3d_simulator_flush(struct v3d_context *v3d,
if (ret)
return ret;
- if (ctex && csim_bo->winsys_map) {
- for (int y = 0; y < ctex->base.height0; y++) {
- memcpy(csim_bo->winsys_map + y * winsys_stride,
- ctex->bo->map + y * sim_stride,
- row_len);
- }
- }
-
return 0;
}
/**
- * Map the underlying GEM object from the real hardware GEM handle.
- */
-static void *
-v3d_simulator_map_winsys_bo(int fd, struct v3d_simulator_bo *sim_bo)
-{
- int ret;
- void *map;
-
- struct drm_mode_map_dumb map_dumb = {
- .handle = sim_bo->handle,
- };
- ret = drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &map_dumb);
- if (ret != 0) {
- fprintf(stderr, "map ioctl failure\n");
- abort();
- }
-
- map = mmap(NULL, sim_bo->size, PROT_READ | PROT_WRITE, MAP_SHARED,
- fd, map_dumb.offset);
- if (map == MAP_FAILED) {
- fprintf(stderr,
- "mmap of bo %d (offset 0x%016llx, size %d) failed\n",
- sim_bo->handle, (long long)map_dumb.offset,
- (int)sim_bo->size);
- abort();
- }
-
- return map;
-}
-
-/**
* Do fixups after a BO has been opened from a handle.
*
* This could be done at DRM_IOCTL_GEM_OPEN/DRM_IOCTL_GEM_PRIME_FD_TO_HANDLE
* time, but we're still using drmPrimeFDToHandle() so we have this helper to
* be called afterward instead.
*/
-void v3d_simulator_open_from_handle(int fd, uint32_t winsys_stride,
- int handle, uint32_t size)
+void v3d_simulator_open_from_handle(int fd, int handle, uint32_t size)
{
- struct v3d_simulator_bo *sim_bo =
- v3d_create_simulator_bo(fd, handle, size);
-
- sim_bo->winsys_stride = winsys_stride;
- sim_bo->winsys_map = v3d_simulator_map_winsys_bo(fd, sim_bo);
+ v3d_create_simulator_bo(fd, handle, size);
}
/**