diff options
author | Christian König <[email protected]> | 2014-09-11 09:29:28 +0200 |
---|---|---|
committer | Christian König <[email protected]> | 2014-09-11 15:05:55 +0200 |
commit | 4bc0059229f212e91ca266ef3f80b652b1cdcb86 (patch) | |
tree | ff01c59ef02a3aba3733ac6dc09c1dc679046e93 /src/gallium/drivers/radeon/radeon_video.c | |
parent | 771ab951a8d3d16f577f0438a8d03544ff32b21f (diff) |
radeon/video: use more of the common buffer code v2
In preparation to using buffers clears with the hw engine(s).
v2: split out flipping to using hw buffer clears.
Signed-off-by: Christian König <[email protected]>
Reviewed-by: Michel Dänzer <[email protected]>
Diffstat (limited to 'src/gallium/drivers/radeon/radeon_video.c')
-rw-r--r-- | src/gallium/drivers/radeon/radeon_video.c | 53 |
1 files changed, 23 insertions, 30 deletions
diff --git a/src/gallium/drivers/radeon/radeon_video.c b/src/gallium/drivers/radeon/radeon_video.c index e935f67a8b7..0bc43907005 100644 --- a/src/gallium/drivers/radeon/radeon_video.c +++ b/src/gallium/drivers/radeon/radeon_video.c @@ -60,48 +60,41 @@ unsigned rvid_alloc_stream_handle() } /* create a buffer in the winsys */ -bool rvid_create_buffer(struct radeon_winsys *ws, struct rvid_buffer *buffer, - unsigned size, enum radeon_bo_domain domain, - enum radeon_bo_flag flags) +bool rvid_create_buffer(struct pipe_screen *screen, struct rvid_buffer *buffer, + unsigned size, unsigned usage) { - buffer->domain = domain; - buffer->flags = flags; + memset(buffer, 0, sizeof(*buffer)); + buffer->usage = usage; + buffer->res = (struct r600_resource *) + pipe_buffer_create(screen, PIPE_BIND_CUSTOM, usage, size); - buffer->buf = ws->buffer_create(ws, size, 4096, false, domain, flags); - if (!buffer->buf) - return false; - - buffer->cs_handle = ws->buffer_get_cs_handle(buffer->buf); - if (!buffer->cs_handle) - return false; - - return true; + return buffer->res != NULL; } /* destroy a buffer */ void rvid_destroy_buffer(struct rvid_buffer *buffer) { - pb_reference(&buffer->buf, NULL); - buffer->cs_handle = NULL; + pipe_resource_reference((struct pipe_resource **)&buffer->res, NULL); } /* reallocate a buffer, preserving its content */ -bool rvid_resize_buffer(struct radeon_winsys *ws, struct radeon_winsys_cs *cs, +bool rvid_resize_buffer(struct pipe_screen *screen, struct radeon_winsys_cs *cs, struct rvid_buffer *new_buf, unsigned new_size) { - unsigned bytes = MIN2(new_buf->buf->size, new_size); + struct r600_common_screen *rscreen = (struct r600_common_screen *)screen; + struct radeon_winsys* ws = rscreen->ws; + unsigned bytes = MIN2(new_buf->res->buf->size, new_size); struct rvid_buffer old_buf = *new_buf; void *src = NULL, *dst = NULL; - if (!rvid_create_buffer(ws, new_buf, new_size, new_buf->domain, - new_buf->flags)) + if (!rvid_create_buffer(screen, new_buf, new_size, new_buf->usage)) goto error; - src = ws->buffer_map(old_buf.cs_handle, cs, PIPE_TRANSFER_READ); + src = ws->buffer_map(old_buf.res->cs_buf, cs, PIPE_TRANSFER_READ); if (!src) goto error; - dst = ws->buffer_map(new_buf->cs_handle, cs, PIPE_TRANSFER_WRITE); + dst = ws->buffer_map(new_buf->res->cs_buf, cs, PIPE_TRANSFER_WRITE); if (!dst) goto error; @@ -111,14 +104,14 @@ bool rvid_resize_buffer(struct radeon_winsys *ws, struct radeon_winsys_cs *cs, dst += bytes; memset(dst, 0, new_size); } - ws->buffer_unmap(new_buf->cs_handle); - ws->buffer_unmap(old_buf.cs_handle); + ws->buffer_unmap(new_buf->res->cs_buf); + ws->buffer_unmap(old_buf.res->cs_buf); rvid_destroy_buffer(&old_buf); return true; error: if (src) - ws->buffer_unmap(old_buf.cs_handle); + ws->buffer_unmap(old_buf.res->cs_buf); rvid_destroy_buffer(new_buf); *new_buf = old_buf; return false; @@ -127,12 +120,12 @@ error: /* clear the buffer with zeros */ void rvid_clear_buffer(struct radeon_winsys *ws, struct radeon_winsys_cs *cs, struct rvid_buffer* buffer) { - void *ptr = ws->buffer_map(buffer->cs_handle, cs, PIPE_TRANSFER_WRITE); - if (!ptr) - return; + void *ptr = ws->buffer_map(buffer->res->cs_buf, cs, PIPE_TRANSFER_WRITE); + if (!ptr) + return; - memset(ptr, 0, buffer->buf->size); - ws->buffer_unmap(buffer->cs_handle); + memset(ptr, 0, buffer->res->buf->size); + ws->buffer_unmap(buffer->res->cs_buf); } /** |