{
struct pipe_screen *screen;
- screen = fd_drm_screen_create(fd);
+ screen = fd_drm_screen_create(fd, NULL);
return screen ? debug_screen_wrap(screen) : NULL;
}
fd_bc_invalidate_resource(rsc, true);
if (rsc->bo)
fd_bo_del(rsc->bo);
+ if (rsc->scanout)
+ renderonly_scanout_destroy(rsc->scanout, fd_screen(pscreen)->ro);
+
util_range_destroy(&rsc->valid_buffer_range);
FREE(rsc);
}
handle->modifier = fd_resource_modifier(rsc);
- return fd_screen_bo_get_handle(pscreen, rsc->bo,
+ return fd_screen_bo_get_handle(pscreen, rsc->bo, rsc->scanout,
rsc->slices[0].pitch * rsc->cpp, handle);
}
const uint64_t *modifiers, int count)
{
struct fd_screen *screen = fd_screen(pscreen);
- struct fd_resource *rsc = CALLOC_STRUCT(fd_resource);
- struct pipe_resource *prsc = &rsc->base;
+ struct fd_resource *rsc;
+ struct pipe_resource *prsc;
enum pipe_format format = tmpl->format;
uint32_t size;
+ if (screen->ro && (tmpl->bind & PIPE_BIND_SCANOUT)) {
+ struct pipe_resource scanout_templat = *tmpl;
+ struct renderonly_scanout *scanout;
+ struct winsys_handle handle;
+
+ scanout = renderonly_scanout_for_resource(&scanout_templat,
+ screen->ro, &handle);
+ if (!scanout)
+ return NULL;
+
+ renderonly_scanout_destroy(scanout, screen->ro);
+
+ assert(handle.type == WINSYS_HANDLE_TYPE_FD);
+ rsc = fd_resource(pscreen->resource_from_handle(pscreen, tmpl,
+ &handle,
+ PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE));
+ close(handle.handle);
+ if (!rsc)
+ return NULL;
+
+ return &rsc->base;
+ }
+
+ rsc = CALLOC_STRUCT(fd_resource);
+ prsc = &rsc->base;
+
DBG("%p: target=%d, format=%s, %ux%ux%u, array_size=%u, last_level=%u, "
"nr_samples=%u, usage=%u, bind=%x, flags=%x", prsc,
tmpl->target, util_format_name(format),
assert(rsc->cpp);
+ if (screen->ro) {
+ rsc->scanout =
+ renderonly_create_gpu_import_for_resource(prsc, screen->ro, NULL);
+ /* failure is expected in some cases.. */
+ }
+
return prsc;
fail:
/* buffer range that has been initialized */
struct util_range valid_buffer_range;
bool valid;
+ struct renderonly_scanout *scanout;
/* reference to the resource holding stencil data for a z32_s8 texture */
/* TODO rename to secondary or auxiliary? */
if (screen->dev)
fd_device_del(screen->dev);
+ if (screen->ro)
+ FREE(screen->ro);
+
fd_bc_fini(&screen->batch_cache);
slab_destroy_parent(&screen->transfer_pool);
boolean
fd_screen_bo_get_handle(struct pipe_screen *pscreen,
struct fd_bo *bo,
+ struct renderonly_scanout *scanout,
unsigned stride,
struct winsys_handle *whandle)
{
if (whandle->type == WINSYS_HANDLE_TYPE_SHARED) {
return fd_bo_get_name(bo, &whandle->handle) == 0;
} else if (whandle->type == WINSYS_HANDLE_TYPE_KMS) {
+ if (renderonly_get_handle(scanout, whandle))
+ return TRUE;
whandle->handle = fd_bo_handle(bo);
return TRUE;
} else if (whandle->type == WINSYS_HANDLE_TYPE_FD) {
}
struct pipe_screen *
-fd_screen_create(struct fd_device *dev)
+fd_screen_create(struct fd_device *dev, struct renderonly *ro)
{
struct fd_screen *screen = CALLOC_STRUCT(fd_screen);
struct pipe_screen *pscreen;
screen->dev = dev;
screen->refcnt = 1;
+ if (ro) {
+ screen->ro = renderonly_dup(ro);
+ if (!screen->ro) {
+ DBG("could not create renderonly object");
+ goto fail;
+ }
+ }
+
// maybe this should be in context?
screen->pipe = fd_pipe_new(screen->dev, FD_PIPE_3D);
if (!screen->pipe) {
#include "util/u_memory.h"
#include "util/slab.h"
#include "os/os_thread.h"
+#include "renderonly/renderonly.h"
#include "freedreno_batch_cache.h"
#include "freedreno_perfcntr.h"
unsigned num_supported_modifiers;
const uint64_t *supported_modifiers;
+
+ struct renderonly *ro;
};
static inline struct fd_screen *
boolean fd_screen_bo_get_handle(struct pipe_screen *pscreen,
struct fd_bo *bo,
+ struct renderonly_scanout *scanout,
unsigned stride,
struct winsys_handle *whandle);
struct fd_bo * fd_screen_bo_from_handle(struct pipe_screen *pscreen,
struct winsys_handle *whandle);
-struct pipe_screen * fd_screen_create(struct fd_device *dev);
+struct pipe_screen *
+fd_screen_create(struct fd_device *dev, struct renderonly *ro);
static inline boolean
is_a20x(struct fd_screen *screen)
{
struct pipe_screen *screen;
- screen = fd_drm_screen_create(fd);
+ screen = fd_drm_screen_create(fd, NULL);
if (!screen)
return NULL;
#define __FREEDRENO_DRM_PUBLIC_H__
struct pipe_screen;
+struct renderonly;
-struct pipe_screen *fd_drm_screen_create(int drmFD);
+struct pipe_screen *fd_drm_screen_create(int drmFD, struct renderonly *ro);
#endif
}
struct pipe_screen *
-fd_drm_screen_create(int fd)
+fd_drm_screen_create(int fd, struct renderonly *ro)
{
struct pipe_screen *pscreen = NULL;
if (!dev)
goto unlock;
- pscreen = fd_screen_create(dev);
+ pscreen = fd_screen_create(dev, ro);
if (pscreen) {
int fd = fd_device_fd(dev);