mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
radeonsi/vcn: Create encode DPB surfaces with PIPE_BIND_VIDEO_ENCODE_DPB
Reviewed-by: Ruijing Dong <ruijing.dong@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32303>
This commit is contained in:
parent
7d27de70af
commit
4da1756be4
3 changed files with 25 additions and 20 deletions
|
|
@ -1235,8 +1235,6 @@ static int setup_dpb(struct radeon_encoder *enc, uint32_t num_reconstructed_pict
|
|||
enc_pic->ctx_buf.rec_luma_pitch = pitch;
|
||||
enc_pic->ctx_buf.pre_encode_picture_luma_pitch = pitch;
|
||||
enc_pic->ctx_buf.num_reconstructed_pictures = num_reconstructed_pictures;
|
||||
enc_pic->dpb_luma_size = luma_size;
|
||||
enc_pic->dpb_chroma_size = chroma_size;
|
||||
enc_pic->total_coloc_bytes = total_coloc_bytes;
|
||||
|
||||
offset = 0;
|
||||
|
|
@ -1884,7 +1882,6 @@ void radeon_enc_create_dpb_aux_buffers(struct radeon_encoder *enc, struct radeon
|
|||
return;
|
||||
|
||||
uint32_t fcb_size = radeon_enc_frame_context_buffer_size(enc);
|
||||
uint32_t recon_size = enc->enc_pic.dpb_luma_size + enc->enc_pic.dpb_chroma_size;
|
||||
|
||||
buf->fcb = CALLOC_STRUCT(rvid_buffer);
|
||||
if (!buf->fcb || !si_vid_create_buffer(enc->screen, buf->fcb, fcb_size, PIPE_USAGE_DEFAULT)) {
|
||||
|
|
@ -1893,11 +1890,13 @@ void radeon_enc_create_dpb_aux_buffers(struct radeon_encoder *enc, struct radeon
|
|||
}
|
||||
|
||||
if (enc->enc_pic.quality_modes.pre_encode_mode) {
|
||||
buf->pre = CALLOC_STRUCT(rvid_buffer);
|
||||
if (!buf->pre || !si_vid_create_buffer(enc->screen, buf->pre, recon_size, PIPE_USAGE_DEFAULT)) {
|
||||
buf->pre = enc->base.context->create_video_buffer(enc->base.context, &buf->templ);
|
||||
if (!buf->pre) {
|
||||
RADEON_ENC_ERR("Can't create preenc buffer!\n");
|
||||
return;
|
||||
}
|
||||
buf->pre_luma = (struct si_texture *)((struct vl_video_buffer *)buf->pre)->resources[0];
|
||||
buf->pre_chroma = (struct si_texture *)((struct vl_video_buffer *)buf->pre)->resources[1];
|
||||
|
||||
buf->pre_fcb = CALLOC_STRUCT(rvid_buffer);
|
||||
if (!buf->pre_fcb || !si_vid_create_buffer(enc->screen, buf->pre_fcb, fcb_size, PIPE_USAGE_DEFAULT)) {
|
||||
|
|
@ -1911,8 +1910,10 @@ static void radeon_enc_destroy_dpb_buffer(void *data)
|
|||
{
|
||||
struct radeon_enc_dpb_buffer *dpb = data;
|
||||
|
||||
if (dpb->pre)
|
||||
dpb->pre->destroy(dpb->pre);
|
||||
|
||||
RADEON_ENC_DESTROY_VIDEO_BUFFER(dpb->fcb);
|
||||
RADEON_ENC_DESTROY_VIDEO_BUFFER(dpb->pre);
|
||||
RADEON_ENC_DESTROY_VIDEO_BUFFER(dpb->pre_fcb);
|
||||
FREE(dpb);
|
||||
}
|
||||
|
|
@ -1923,13 +1924,16 @@ static struct pipe_video_buffer *radeon_enc_create_dpb_buffer(struct pipe_video_
|
|||
{
|
||||
struct radeon_encoder *enc = (struct radeon_encoder *)encoder;
|
||||
|
||||
struct pipe_video_buffer *buf = enc->base.context->create_video_buffer(enc->base.context, templat);
|
||||
struct pipe_video_buffer templ = *templat;
|
||||
templ.bind |= PIPE_BIND_VIDEO_ENCODE_DPB;
|
||||
struct pipe_video_buffer *buf = enc->base.context->create_video_buffer(enc->base.context, &templ);
|
||||
if (!buf) {
|
||||
RADEON_ENC_ERR("Can't create dpb buffer!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct radeon_enc_dpb_buffer *dpb = CALLOC_STRUCT(radeon_enc_dpb_buffer);
|
||||
dpb->templ = templ;
|
||||
dpb->luma = (struct si_texture *)((struct vl_video_buffer *)buf)->resources[0];
|
||||
dpb->chroma = (struct si_texture *)((struct vl_video_buffer *)buf)->resources[1];
|
||||
|
||||
|
|
|
|||
|
|
@ -64,10 +64,13 @@ struct pipe_video_codec *radeon_create_encoder(struct pipe_context *context,
|
|||
radeon_enc_get_buffer get_buffer);
|
||||
|
||||
struct radeon_enc_dpb_buffer {
|
||||
struct pipe_video_buffer templ, *pre;
|
||||
|
||||
struct si_texture *luma; /* recon luma */
|
||||
struct si_texture *chroma; /* recon chroma */
|
||||
struct rvid_buffer *fcb; /* frame context buffer*/
|
||||
struct rvid_buffer *pre; /* preenc recon */
|
||||
struct si_texture *pre_luma; /* preenc recon luma */
|
||||
struct si_texture *pre_chroma;/* preenc recon chroma */
|
||||
struct rvid_buffer *pre_fcb; /* preenc frame context buffer */
|
||||
};
|
||||
|
||||
|
|
@ -100,8 +103,6 @@ struct radeon_enc_pic {
|
|||
unsigned nal_unit_type;
|
||||
unsigned temporal_id;
|
||||
unsigned num_temporal_layers;
|
||||
unsigned dpb_luma_size;
|
||||
unsigned dpb_chroma_size;
|
||||
unsigned total_coloc_bytes;
|
||||
rvcn_enc_quality_modes_t quality_modes;
|
||||
|
||||
|
|
|
|||
|
|
@ -280,7 +280,6 @@ static void radeon_enc_ctx(struct radeon_encoder *enc)
|
|||
static void radeon_enc_ctx_tier2(struct radeon_encoder *enc)
|
||||
{
|
||||
uint32_t num_refs = 0;
|
||||
uint32_t swizzle_mode = radeon_enc_ref_swizzle_mode(enc);
|
||||
bool is_h264 = u_reduce_video_profile(enc->base.profile)
|
||||
== PIPE_VIDEO_FORMAT_MPEG4_AVC;
|
||||
bool is_av1 = u_reduce_video_profile(enc->base.profile)
|
||||
|
|
@ -318,7 +317,7 @@ static void radeon_enc_ctx_tier2(struct radeon_encoder *enc)
|
|||
RADEON_ENC_CS(0);
|
||||
RADEON_ENC_CS(0);
|
||||
RADEON_ENC_CS(0);
|
||||
RADEON_ENC_CS(swizzle_mode);
|
||||
RADEON_ENC_CS(luma->surface.u.gfx9.swizzle_mode);
|
||||
RADEON_ENC_READWRITE(fcb->res->buf, fcb->res->domains, 0);
|
||||
if (is_h264) {
|
||||
RADEON_ENC_CS(enc->enc_pic.fcb_offset.h264.colloc_buffer_offset);
|
||||
|
|
@ -340,17 +339,18 @@ static void radeon_enc_ctx_tier2(struct radeon_encoder *enc)
|
|||
RADEON_ENC_CS(0);
|
||||
continue;
|
||||
}
|
||||
struct rvid_buffer *pre = enc->enc_pic.dpb_bufs[i]->pre;
|
||||
struct rvid_buffer *pre_fcb = enc->enc_pic.dpb_bufs[i]->pre_fcb;
|
||||
RADEON_ENC_READWRITE(pre->res->buf, pre->res->domains, 0);
|
||||
RADEON_ENC_CS(enc->enc_pic.ctx_buf.rec_luma_pitch);
|
||||
RADEON_ENC_READWRITE(pre->res->buf, pre->res->domains, enc->enc_pic.dpb_luma_size);
|
||||
RADEON_ENC_CS(enc->enc_pic.ctx_buf.rec_chroma_pitch);
|
||||
struct si_texture *luma = enc->enc_pic.dpb_bufs[i]->pre_luma;
|
||||
struct si_texture *chroma = enc->enc_pic.dpb_bufs[i]->pre_chroma;
|
||||
struct rvid_buffer *fcb = enc->enc_pic.dpb_bufs[i]->pre_fcb;
|
||||
RADEON_ENC_READWRITE(luma->buffer.buf, luma->buffer.domains, luma->surface.u.gfx9.surf_offset);
|
||||
RADEON_ENC_CS(luma->surface.u.gfx9.surf_pitch);
|
||||
RADEON_ENC_READWRITE(chroma->buffer.buf, chroma->buffer.domains, chroma->surface.u.gfx9.surf_offset);
|
||||
RADEON_ENC_CS(chroma->surface.u.gfx9.surf_pitch);
|
||||
RADEON_ENC_CS(0);
|
||||
RADEON_ENC_CS(0);
|
||||
RADEON_ENC_CS(0);
|
||||
RADEON_ENC_CS(swizzle_mode);
|
||||
RADEON_ENC_READWRITE(pre_fcb->res->buf, pre_fcb->res->domains, 0);
|
||||
RADEON_ENC_CS(luma->surface.u.gfx9.swizzle_mode);
|
||||
RADEON_ENC_READWRITE(fcb->res->buf, fcb->res->domains, 0);
|
||||
if (is_h264) {
|
||||
RADEON_ENC_CS(enc->enc_pic.fcb_offset.h264.colloc_buffer_offset);
|
||||
RADEON_ENC_CS(0);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue