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;
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
}
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
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);
return NULL;
}
- return v3d_bo_open_handle(screen, winsys_stride, handle, size);
+ return v3d_bo_open_handle(screen, handle, size);
}
int
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);
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)
}
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;
}
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;
rsc->internal_format = prsc->format;
- v3d_setup_slices(rsc);
+ v3d_setup_slices(rsc, 0);
if (!v3d_resource_bo_alloc(rsc))
goto fail;
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,
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) {
uint32_t size;
void *vaddr;
- void *winsys_map;
- uint32_t winsys_stride;
-
int handle;
};
{
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);
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;
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.
*
* 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);
}
/**