summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/radeon/radeon_uvd.c40
-rw-r--r--src/gallium/drivers/radeon/radeon_vce.c17
-rw-r--r--src/gallium/drivers/radeon/radeon_vce.h1
-rw-r--r--src/gallium/drivers/radeon/radeon_vce_40_2_2.c5
-rw-r--r--src/gallium/drivers/radeon/radeon_video.c53
-rw-r--r--src/gallium/drivers/radeon/radeon_video.h13
6 files changed, 62 insertions, 67 deletions
diff --git a/src/gallium/drivers/radeon/radeon_uvd.c b/src/gallium/drivers/radeon/radeon_uvd.c
index 9d3b2bff12a..6ad2d2476f3 100644
--- a/src/gallium/drivers/radeon/radeon_uvd.c
+++ b/src/gallium/drivers/radeon/radeon_uvd.c
@@ -68,6 +68,7 @@ struct ruvd_decoder {
unsigned stream_handle;
unsigned frame_number;
+ struct pipe_screen *screen;
struct radeon_winsys* ws;
struct radeon_winsys_cs* cs;
@@ -122,7 +123,7 @@ static void map_msg_fb_buf(struct ruvd_decoder *dec)
buf = &dec->msg_fb_buffers[dec->cur_buffer];
/* and map it for CPU access */
- ptr = dec->ws->buffer_map(buf->cs_handle, dec->cs, PIPE_TRANSFER_WRITE);
+ ptr = dec->ws->buffer_map(buf->res->cs_buf, dec->cs, PIPE_TRANSFER_WRITE);
/* calc buffer offsets */
dec->msg = (struct ruvd_msg *)ptr;
@@ -142,12 +143,12 @@ static void send_msg_buf(struct ruvd_decoder *dec)
buf = &dec->msg_fb_buffers[dec->cur_buffer];
/* unmap the buffer */
- dec->ws->buffer_unmap(buf->cs_handle);
+ dec->ws->buffer_unmap(buf->res->cs_buf);
dec->msg = NULL;
dec->fb = NULL;
/* and send it to the hardware */
- send_cmd(dec, RUVD_CMD_MSG_BUFFER, buf->cs_handle, 0,
+ send_cmd(dec, RUVD_CMD_MSG_BUFFER, buf->res->cs_buf, 0,
RADEON_USAGE_READ, RADEON_DOMAIN_GTT);
}
@@ -601,7 +602,7 @@ static void ruvd_begin_frame(struct pipe_video_codec *decoder,
dec->bs_size = 0;
dec->bs_ptr = dec->ws->buffer_map(
- dec->bs_buffers[dec->cur_buffer].cs_handle,
+ dec->bs_buffers[dec->cur_buffer].res->cs_buf,
dec->cs, PIPE_TRANSFER_WRITE);
}
@@ -640,14 +641,14 @@ static void ruvd_decode_bitstream(struct pipe_video_codec *decoder,
struct rvid_buffer *buf = &dec->bs_buffers[dec->cur_buffer];
unsigned new_size = dec->bs_size + sizes[i];
- if (new_size > buf->buf->size) {
- dec->ws->buffer_unmap(buf->cs_handle);
- if (!rvid_resize_buffer(dec->ws, dec->cs, buf, new_size)) {
+ if (new_size > buf->res->buf->size) {
+ dec->ws->buffer_unmap(buf->res->cs_buf);
+ if (!rvid_resize_buffer(dec->screen, dec->cs, buf, new_size)) {
RVID_ERR("Can't resize bitstream buffer!");
return;
}
- dec->bs_ptr = dec->ws->buffer_map(buf->cs_handle, dec->cs,
+ dec->bs_ptr = dec->ws->buffer_map(buf->res->cs_buf, dec->cs,
PIPE_TRANSFER_WRITE);
if (!dec->bs_ptr)
return;
@@ -683,7 +684,7 @@ static void ruvd_end_frame(struct pipe_video_codec *decoder,
bs_size = align(dec->bs_size, 128);
memset(dec->bs_ptr, 0, bs_size - dec->bs_size);
- dec->ws->buffer_unmap(bs_buf->cs_handle);
+ dec->ws->buffer_unmap(bs_buf->res->cs_buf);
map_msg_fb_buf(dec);
dec->msg->size = sizeof(*dec->msg);
@@ -696,7 +697,7 @@ static void ruvd_end_frame(struct pipe_video_codec *decoder,
dec->msg->body.decode.width_in_samples = dec->base.width;
dec->msg->body.decode.height_in_samples = dec->base.height;
- dec->msg->body.decode.dpb_size = dec->dpb.buf->size;
+ dec->msg->body.decode.dpb_size = dec->dpb.res->buf->size;
dec->msg->body.decode.bsd_size = bs_size;
dt = dec->set_dtb(dec->msg, (struct vl_video_buffer *)target);
@@ -731,13 +732,13 @@ static void ruvd_end_frame(struct pipe_video_codec *decoder,
send_msg_buf(dec);
- send_cmd(dec, RUVD_CMD_DPB_BUFFER, dec->dpb.cs_handle, 0,
+ send_cmd(dec, RUVD_CMD_DPB_BUFFER, dec->dpb.res->cs_buf, 0,
RADEON_USAGE_READWRITE, RADEON_DOMAIN_VRAM);
- send_cmd(dec, RUVD_CMD_BITSTREAM_BUFFER, bs_buf->cs_handle,
+ send_cmd(dec, RUVD_CMD_BITSTREAM_BUFFER, bs_buf->res->cs_buf,
0, RADEON_USAGE_READ, RADEON_DOMAIN_GTT);
send_cmd(dec, RUVD_CMD_DECODING_TARGET_BUFFER, dt, 0,
RADEON_USAGE_WRITE, RADEON_DOMAIN_VRAM);
- send_cmd(dec, RUVD_CMD_FEEDBACK_BUFFER, msg_fb_buf->cs_handle,
+ send_cmd(dec, RUVD_CMD_FEEDBACK_BUFFER, msg_fb_buf->res->cs_buf,
FB_BUFFER_OFFSET, RADEON_USAGE_WRITE, RADEON_DOMAIN_GTT);
set_reg(dec, RUVD_ENGINE_CNTL, 1);
@@ -805,6 +806,7 @@ struct pipe_video_codec *ruvd_create_decoder(struct pipe_context *context,
dec->set_dtb = set_dtb;
dec->stream_handle = rvid_alloc_stream_handle();
+ dec->screen = context->screen;
dec->ws = ws;
dec->cs = ws->cs_create(ws, RING_UVD, NULL, NULL, NULL);
if (!dec->cs) {
@@ -816,14 +818,14 @@ struct pipe_video_codec *ruvd_create_decoder(struct pipe_context *context,
for (i = 0; i < NUM_BUFFERS; ++i) {
unsigned msg_fb_size = FB_BUFFER_OFFSET + FB_BUFFER_SIZE;
STATIC_ASSERT(sizeof(struct ruvd_msg) <= FB_BUFFER_OFFSET);
- if (!rvid_create_buffer(dec->ws, &dec->msg_fb_buffers[i], msg_fb_size,
- RADEON_DOMAIN_VRAM, 0)) {
+ if (!rvid_create_buffer(dec->screen, &dec->msg_fb_buffers[i],
+ msg_fb_size, PIPE_USAGE_DEFAULT)) {
RVID_ERR("Can't allocated message buffers.\n");
goto error;
}
- if (!rvid_create_buffer(dec->ws, &dec->bs_buffers[i], bs_buf_size,
- RADEON_DOMAIN_GTT, 0)) {
+ if (!rvid_create_buffer(dec->screen, &dec->bs_buffers[i],
+ bs_buf_size, PIPE_USAGE_STAGING)) {
RVID_ERR("Can't allocated bitstream buffers.\n");
goto error;
}
@@ -832,7 +834,7 @@ struct pipe_video_codec *ruvd_create_decoder(struct pipe_context *context,
rvid_clear_buffer(dec->ws, dec->cs, &dec->bs_buffers[i]);
}
- if (!rvid_create_buffer(dec->ws, &dec->dpb, dpb_size, RADEON_DOMAIN_VRAM, 0)) {
+ if (!rvid_create_buffer(dec->screen, &dec->dpb, dpb_size, PIPE_USAGE_DEFAULT)) {
RVID_ERR("Can't allocated dpb.\n");
goto error;
}
@@ -846,7 +848,7 @@ struct pipe_video_codec *ruvd_create_decoder(struct pipe_context *context,
dec->msg->body.create.stream_type = profile2stream_type(dec->base.profile);
dec->msg->body.create.width_in_samples = dec->base.width;
dec->msg->body.create.height_in_samples = dec->base.height;
- dec->msg->body.create.dpb_size = dec->dpb.buf->size;
+ dec->msg->body.create.dpb_size = dec->dpb.res->buf->size;
send_msg_buf(dec);
flush(dec);
next_buffer(dec);
diff --git a/src/gallium/drivers/radeon/radeon_vce.c b/src/gallium/drivers/radeon/radeon_vce.c
index b7b88a3fdf0..27a3832da83 100644
--- a/src/gallium/drivers/radeon/radeon_vce.c
+++ b/src/gallium/drivers/radeon/radeon_vce.c
@@ -56,7 +56,7 @@ static void flush(struct rvce_encoder *enc)
#if 0
static void dump_feedback(struct rvce_encoder *enc, struct rvid_buffer *fb)
{
- uint32_t *ptr = enc->ws->buffer_map(fb->cs_handle, enc->cs, PIPE_TRANSFER_READ_WRITE);
+ uint32_t *ptr = enc->ws->buffer_map(fb->res->cs_buf, enc->cs, PIPE_TRANSFER_READ_WRITE);
unsigned i = 0;
fprintf(stderr, "\n");
fprintf(stderr, "encStatus:\t\t\t%08x\n", ptr[i++]);
@@ -75,7 +75,7 @@ static void dump_feedback(struct rvce_encoder *enc, struct rvid_buffer *fb)
fprintf(stderr, "seiPrivatePackageOffset:\t%08x\n", ptr[i++]);
fprintf(stderr, "seiPrivatePackageSize:\t\t%08x\n", ptr[i++]);
fprintf(stderr, "\n");
- enc->ws->buffer_unmap(fb->cs_handle);
+ enc->ws->buffer_unmap(fb->res->cs_buf);
}
#endif
@@ -191,7 +191,7 @@ static void rvce_destroy(struct pipe_video_codec *encoder)
struct rvce_encoder *enc = (struct rvce_encoder*)encoder;
if (enc->stream_handle) {
struct rvid_buffer fb;
- rvid_create_buffer(enc->ws, &fb, 512, RADEON_DOMAIN_GTT, 0);
+ rvid_create_buffer(enc->screen, &fb, 512, PIPE_USAGE_STAGING);
enc->fb = &fb;
enc->session(enc);
enc->feedback(enc);
@@ -233,7 +233,7 @@ static void rvce_begin_frame(struct pipe_video_codec *encoder,
if (!enc->stream_handle) {
struct rvid_buffer fb;
enc->stream_handle = rvid_alloc_stream_handle();
- rvid_create_buffer(enc->ws, &fb, 512, RADEON_DOMAIN_GTT, 0);
+ rvid_create_buffer(enc->screen, &fb, 512, PIPE_USAGE_STAGING);
enc->fb = &fb;
enc->session(enc);
enc->create(enc);
@@ -265,7 +265,7 @@ static void rvce_encode_bitstream(struct pipe_video_codec *encoder,
enc->bs_size = destination->width0;
*fb = enc->fb = CALLOC_STRUCT(rvid_buffer);
- if (!rvid_create_buffer(enc->ws, enc->fb, 512, RADEON_DOMAIN_GTT, 0)) {
+ if (!rvid_create_buffer(enc->screen, enc->fb, 512, PIPE_USAGE_STAGING)) {
RVID_ERR("Can't create feedback buffer.\n");
return;
}
@@ -300,7 +300,7 @@ static void rvce_get_feedback(struct pipe_video_codec *encoder,
struct rvid_buffer *fb = feedback;
if (size) {
- uint32_t *ptr = enc->ws->buffer_map(fb->cs_handle, enc->cs, PIPE_TRANSFER_READ_WRITE);
+ uint32_t *ptr = enc->ws->buffer_map(fb->res->cs_buf, enc->cs, PIPE_TRANSFER_READ_WRITE);
if (ptr[1]) {
*size = ptr[4] - ptr[9];
@@ -308,7 +308,7 @@ static void rvce_get_feedback(struct pipe_video_codec *encoder,
*size = 0;
}
- enc->ws->buffer_unmap(fb->cs_handle);
+ enc->ws->buffer_unmap(fb->res->cs_buf);
}
//dump_feedback(enc, fb);
rvid_destroy_buffer(fb);
@@ -363,6 +363,7 @@ struct pipe_video_codec *rvce_create_encoder(struct pipe_context *context,
enc->base.get_feedback = rvce_get_feedback;
enc->get_buffer = get_buffer;
+ enc->screen = context->screen;
enc->ws = ws;
enc->cs = ws->cs_create(ws, RING_VCE, rvce_cs_flush, enc, NULL);
if (!enc->cs) {
@@ -390,7 +391,7 @@ struct pipe_video_codec *rvce_create_encoder(struct pipe_context *context,
cpb_size = cpb_size * 3 / 2;
cpb_size = cpb_size * enc->cpb_num;
tmp_buf->destroy(tmp_buf);
- if (!rvid_create_buffer(enc->ws, &enc->cpb, cpb_size, RADEON_DOMAIN_VRAM, 0)) {
+ if (!rvid_create_buffer(enc->screen, &enc->cpb, cpb_size, PIPE_USAGE_DEFAULT)) {
RVID_ERR("Can't create CPB buffer.\n");
goto error;
}
diff --git a/src/gallium/drivers/radeon/radeon_vce.h b/src/gallium/drivers/radeon/radeon_vce.h
index f1dea8ae904..11febc820db 100644
--- a/src/gallium/drivers/radeon/radeon_vce.h
+++ b/src/gallium/drivers/radeon/radeon_vce.h
@@ -80,6 +80,7 @@ struct rvce_encoder {
unsigned stream_handle;
+ struct pipe_screen *screen;
struct radeon_winsys* ws;
struct radeon_winsys_cs* cs;
diff --git a/src/gallium/drivers/radeon/radeon_vce_40_2_2.c b/src/gallium/drivers/radeon/radeon_vce_40_2_2.c
index 6b5da47eec8..06d3e953f59 100644
--- a/src/gallium/drivers/radeon/radeon_vce_40_2_2.c
+++ b/src/gallium/drivers/radeon/radeon_vce_40_2_2.c
@@ -41,6 +41,7 @@
#include "vl/vl_video_buffer.h"
#include "radeon/drm/radeon_winsys.h"
+#include "r600_pipe_common.h"
#include "radeon_video.h"
#include "radeon_vce.h"
@@ -94,7 +95,7 @@ static void task_info(struct rvce_encoder *enc, uint32_t taskOperation)
static void feedback(struct rvce_encoder *enc)
{
RVCE_BEGIN(0x05000005); // feedback buffer
- RVCE_WRITE(enc->fb->cs_handle, enc->fb->domain); // feedbackRingAddressHi
+ RVCE_WRITE(enc->fb->res->cs_buf, enc->fb->res->domains); // feedbackRingAddressHi
RVCE_CS(0x00000000); // feedbackRingAddressLo
RVCE_CS(0x00000001); // feedbackRingSize
RVCE_END();
@@ -255,7 +256,7 @@ static void encode(struct rvce_encoder *enc)
task_info(enc, 0x00000003);
RVCE_BEGIN(0x05000001); // context buffer
- RVCE_READWRITE(enc->cpb.cs_handle, enc->cpb.domain); // encodeContextAddressHi
+ RVCE_READWRITE(enc->cpb.res->cs_buf, enc->cpb.res->domains); // encodeContextAddressHi
RVCE_CS(0x00000000); // encodeContextAddressLo
RVCE_END();
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);
}
/**
diff --git a/src/gallium/drivers/radeon/radeon_video.h b/src/gallium/drivers/radeon/radeon_video.h
index 01936389f54..fe3088a0b96 100644
--- a/src/gallium/drivers/radeon/radeon_video.h
+++ b/src/gallium/drivers/radeon/radeon_video.h
@@ -43,25 +43,22 @@
/* video buffer representation */
struct rvid_buffer
{
- enum radeon_bo_domain domain;
- enum radeon_bo_flag flags;
- struct pb_buffer* buf;
- struct radeon_winsys_cs_handle* cs_handle;
+ unsigned usage;
+ struct r600_resource *res;
};
/* generate an stream handle */
unsigned rvid_alloc_stream_handle(void);
/* 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);
/* destroy a buffer */
void rvid_destroy_buffer(struct rvid_buffer *buffer);
/* 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);
/* clear the buffer with zeros */