summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/renderonly
diff options
context:
space:
mode:
authorLucas Stach <[email protected]>2017-06-09 18:23:16 +0200
committerLucas Stach <[email protected]>2017-07-19 16:26:49 +0200
commitc4818808991134cc7d7741c8f29dc50f6d2102a0 (patch)
tree79added36f8a71a9687360cb024988e5822e4fe8 /src/gallium/auxiliary/renderonly
parenta9fad437f7ad1c1a8c0a694c2d8b4b6ad4d32098 (diff)
renderonly/etnaviv: stop importing resource from renderonly
The current way of importing the resource from renderonly after allocation is opaque and is taking away control from the driver, which it needs in order to implement more advanced scenarios than the simple linear scanout with matching stride alignments. Signed-off-by: Lucas Stach <[email protected]> Reviewed-by: Christian Gmeiner <[email protected]> Acked-by: Daniel Stone <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/renderonly')
-rw-r--r--src/gallium/auxiliary/renderonly/renderonly.c52
-rw-r--r--src/gallium/auxiliary/renderonly/renderonly.h20
2 files changed, 24 insertions, 48 deletions
diff --git a/src/gallium/auxiliary/renderonly/renderonly.c b/src/gallium/auxiliary/renderonly/renderonly.c
index d3ed214f4e4..da91f12b2ea 100644
--- a/src/gallium/auxiliary/renderonly/renderonly.c
+++ b/src/gallium/auxiliary/renderonly/renderonly.c
@@ -50,27 +50,12 @@ renderonly_dup(const struct renderonly *ro)
return copy;
}
-struct renderonly_scanout *
-renderonly_scanout_for_prime(struct pipe_resource *rsc, struct renderonly *ro)
-{
- struct renderonly_scanout *scanout;
-
- scanout = CALLOC_STRUCT(renderonly_scanout);
- if (!scanout)
- return NULL;
-
- scanout->prime = rsc;
-
- return scanout;
-}
-
void
renderonly_scanout_destroy(struct renderonly_scanout *scanout,
struct renderonly *ro)
{
struct drm_mode_destroy_dumb destroy_dumb = { };
- pipe_resource_reference(&scanout->prime, NULL);
if (ro->kms_fd != -1) {
destroy_dumb.handle = scanout->handle;
drmIoctl(ro->kms_fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_dumb);
@@ -80,12 +65,11 @@ renderonly_scanout_destroy(struct renderonly_scanout *scanout,
struct renderonly_scanout *
renderonly_create_kms_dumb_buffer_for_resource(struct pipe_resource *rsc,
- struct renderonly *ro)
+ struct renderonly *ro,
+ struct winsys_handle *out_handle)
{
- struct pipe_screen *screen = rsc->screen;
struct renderonly_scanout *scanout;
- struct winsys_handle handle;
- int prime_fd, err;
+ int err;
struct drm_mode_create_dumb create_dumb = {
.width = rsc->width0,
.height = rsc->height0,
@@ -108,30 +92,21 @@ renderonly_create_kms_dumb_buffer_for_resource(struct pipe_resource *rsc,
scanout->handle = create_dumb.handle;
scanout->stride = create_dumb.pitch;
- /* export dumb buffer */
+ if (!out_handle)
+ return scanout;
+
+ /* fill in winsys handle */
+ memset(out_handle, 0, sizeof(*out_handle));
+ out_handle->type = DRM_API_HANDLE_TYPE_FD;
+ out_handle->stride = create_dumb.pitch;
+
err = drmPrimeHandleToFD(ro->kms_fd, create_dumb.handle, O_CLOEXEC,
- &prime_fd);
+ (int *)&out_handle->handle);
if (err < 0) {
fprintf(stderr, "failed to export dumb buffer: %s\n", strerror(errno));
goto free_dumb;
}
- /* import dumb buffer */
- memset(&handle, 0, sizeof(handle));
- handle.type = DRM_API_HANDLE_TYPE_FD;
- handle.handle = prime_fd;
- handle.stride = create_dumb.pitch;
-
- scanout->prime = screen->resource_from_handle(screen, rsc,
- &handle, PIPE_HANDLE_USAGE_READ_WRITE);
-
- close(prime_fd);
-
- if (!scanout->prime) {
- fprintf(stderr, "failed to create resource_from_handle: %s\n", strerror(errno));
- goto free_dumb;
- }
-
return scanout;
free_dumb:
@@ -146,7 +121,8 @@ free_scanout:
struct renderonly_scanout *
renderonly_create_gpu_import_for_resource(struct pipe_resource *rsc,
- struct renderonly *ro)
+ struct renderonly *ro,
+ struct winsys_handle *out_handle)
{
struct pipe_screen *screen = rsc->screen;
struct renderonly_scanout *scanout;
diff --git a/src/gallium/auxiliary/renderonly/renderonly.h b/src/gallium/auxiliary/renderonly/renderonly.h
index 70641c45878..6a89c29e2ef 100644
--- a/src/gallium/auxiliary/renderonly/renderonly.h
+++ b/src/gallium/auxiliary/renderonly/renderonly.h
@@ -34,8 +34,6 @@
struct renderonly_scanout {
uint32_t handle;
uint32_t stride;
-
- struct pipe_resource *prime;
};
struct renderonly {
@@ -59,7 +57,8 @@ struct renderonly {
* to be done in flush_resource(..) like a resolve to linear.
*/
struct renderonly_scanout *(*create_for_resource)(struct pipe_resource *rsc,
- struct renderonly *ro);
+ struct renderonly *ro,
+ struct winsys_handle *out_handle);
int kms_fd;
int gpu_fd;
};
@@ -68,14 +67,13 @@ struct renderonly *
renderonly_dup(const struct renderonly *ro);
static inline struct renderonly_scanout *
-renderonly_scanout_for_resource(struct pipe_resource *rsc, struct renderonly *ro)
+renderonly_scanout_for_resource(struct pipe_resource *rsc,
+ struct renderonly *ro,
+ struct winsys_handle *out_handle)
{
- return ro->create_for_resource(rsc, ro);
+ return ro->create_for_resource(rsc, ro, out_handle);
}
-struct renderonly_scanout *
-renderonly_scanout_for_prime(struct pipe_resource *rsc, struct renderonly *ro);
-
void
renderonly_scanout_destroy(struct renderonly_scanout *scanout,
struct renderonly *ro);
@@ -99,13 +97,15 @@ renderonly_get_handle(struct renderonly_scanout *scanout,
*/
struct renderonly_scanout *
renderonly_create_kms_dumb_buffer_for_resource(struct pipe_resource *rsc,
- struct renderonly *ro);
+ struct renderonly *ro,
+ struct winsys_handle *out_handle);
/**
* Import GPU resource into scanout hw.
*/
struct renderonly_scanout *
renderonly_create_gpu_import_for_resource(struct pipe_resource *rsc,
- struct renderonly *ro);
+ struct renderonly *ro,
+ struct winsys_handle *out_handle);
#endif /* RENDERONLY_H_ */