mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-09 05:48:18 +02:00
radeonsi: Move functions from radeon_video.c to si_video.c
And remove radeon_video.c/h Reviewed-by: Ruijing Dong <ruijing.dong@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39627>
This commit is contained in:
parent
528b5c56d2
commit
af5b9d7a4e
18 changed files with 115 additions and 149 deletions
|
|
@ -102,8 +102,6 @@ files_libradeonsi = files(
|
|||
'radeon_vcn_enc_3_0.c',
|
||||
'radeon_vcn_enc_4_0.c',
|
||||
'radeon_vcn_enc_5_0.c',
|
||||
'radeon_video.c',
|
||||
'radeon_video.h',
|
||||
'radeon_bitstream.h',
|
||||
'radeon_bitstream.c',
|
||||
)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
#include "radeon_uvd_enc.h"
|
||||
|
||||
#include "pipe/p_video_codec.h"
|
||||
#include "radeon_video.h"
|
||||
#include "radeon_bitstream.h"
|
||||
#include "radeonsi/si_pipe.h"
|
||||
#include "util/u_memory.h"
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#ifndef _RADEON_UVD_ENC_H
|
||||
#define _RADEON_UVD_ENC_H
|
||||
|
||||
#include "radeon_video.h"
|
||||
#include "si_video.h"
|
||||
|
||||
#define RENC_UVD_FW_INTERFACE_MAJOR_VERSION 1
|
||||
#define RENC_UVD_FW_INTERFACE_MINOR_VERSION 1
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
#include "radeon_vce.h"
|
||||
|
||||
#include "pipe/p_video_codec.h"
|
||||
#include "radeon_video.h"
|
||||
#include "radeon_bitstream.h"
|
||||
#include "radeonsi/si_pipe.h"
|
||||
#include "util/u_memory.h"
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#ifndef RADEON_VCE_H
|
||||
#define RADEON_VCE_H
|
||||
|
||||
#include "radeon_video.h"
|
||||
#include "si_video.h"
|
||||
#include "util/list.h"
|
||||
|
||||
#define RVCE_CS(value) (enc->cs.current.buf[enc->cs.current.cdw++] = (value))
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#ifndef RADEON_VCN_H
|
||||
#define RADEON_VCN_H
|
||||
|
||||
#include "radeon_video.h"
|
||||
#include "si_video.h"
|
||||
|
||||
#include "ac_vcn.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@
|
|||
#include "ac_vcn_enc_av1_default_cdf.h"
|
||||
#include "ac_debug.h"
|
||||
|
||||
#include "pipe/p_video_codec.h"
|
||||
#include "radeon_video.h"
|
||||
#include "si_video.h"
|
||||
#include "radeonsi/si_pipe.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_video.h"
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include "radeon_vcn.h"
|
||||
#include "util/macros.h"
|
||||
#include "radeon_bitstream.h"
|
||||
#include "pipe/p_video_codec.h"
|
||||
|
||||
#include "ac_vcn_enc.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "pipe/p_video_codec.h"
|
||||
#include "radeon_vcn_enc.h"
|
||||
#include "radeon_video.h"
|
||||
#include "si_video.h"
|
||||
#include "si_pipe.h"
|
||||
#include "util/u_video.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "pipe/p_video_codec.h"
|
||||
#include "radeon_vcn_enc.h"
|
||||
#include "radeon_video.h"
|
||||
#include "si_video.h"
|
||||
#include "si_pipe.h"
|
||||
#include "util/u_video.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
#include "util/u_video.h"
|
||||
|
||||
#include "si_pipe.h"
|
||||
#include "radeon_video.h"
|
||||
#include "si_video.h"
|
||||
#include "radeon_vcn_enc.h"
|
||||
|
||||
#define RENCODE_FW_INTERFACE_MAJOR_VERSION 1
|
||||
|
|
|
|||
|
|
@ -1,92 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include "radeon_video.h"
|
||||
#include "ac_uvd_dec.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
/* generate an stream handle */
|
||||
unsigned si_vid_alloc_stream_handle()
|
||||
{
|
||||
static struct ac_uvd_stream_handle stream_handle;
|
||||
if (!stream_handle.base)
|
||||
ac_uvd_init_stream_handle(&stream_handle);
|
||||
return ac_uvd_alloc_stream_handle(&stream_handle);
|
||||
}
|
||||
|
||||
/* reallocate a buffer, preserving its content */
|
||||
bool si_vid_resize_buffer(struct pipe_context *context,
|
||||
struct si_resource **buf, unsigned new_size,
|
||||
struct rvid_buf_offset_info *buf_ofst_info)
|
||||
{
|
||||
struct si_context *sctx = (struct si_context *)context;
|
||||
struct si_screen *sscreen = (struct si_screen *)context->screen;
|
||||
struct radeon_winsys *ws = sscreen->ws;
|
||||
struct si_resource *new_buf = *buf;
|
||||
unsigned bytes = MIN2(new_buf->buf->size, new_size);
|
||||
struct si_resource *old_buf = new_buf;
|
||||
void *src = NULL, *dst = NULL;
|
||||
|
||||
new_buf = si_resource(pipe_buffer_create(context->screen, old_buf->b.b.bind, old_buf->b.b.usage, new_size));
|
||||
if (!new_buf)
|
||||
goto error;
|
||||
|
||||
if (old_buf->b.b.usage == PIPE_USAGE_STAGING) {
|
||||
src = ws->buffer_map(ws, old_buf->buf, NULL, PIPE_MAP_READ | RADEON_MAP_TEMPORARY);
|
||||
if (!src)
|
||||
goto error;
|
||||
|
||||
dst = ws->buffer_map(ws, new_buf->buf, NULL, PIPE_MAP_WRITE | RADEON_MAP_TEMPORARY);
|
||||
if (!dst)
|
||||
goto error;
|
||||
|
||||
if (buf_ofst_info) {
|
||||
memset(dst, 0, new_size);
|
||||
for(int i =0; i < buf_ofst_info->num_units; i++) {
|
||||
memcpy(dst, src, buf_ofst_info->old_offset);
|
||||
dst += buf_ofst_info->new_offset;
|
||||
src += buf_ofst_info->old_offset;
|
||||
}
|
||||
} else {
|
||||
memcpy(dst, src, bytes);
|
||||
if (new_size > bytes) {
|
||||
new_size -= bytes;
|
||||
dst += bytes;
|
||||
memset(dst, 0, new_size);
|
||||
}
|
||||
}
|
||||
ws->buffer_unmap(ws, new_buf->buf);
|
||||
ws->buffer_unmap(ws, old_buf->buf);
|
||||
} else {
|
||||
si_barrier_before_simple_buffer_op(sctx, 0, &new_buf->b.b, &old_buf->b.b);
|
||||
if (buf_ofst_info) {
|
||||
uint64_t dst_offset = 0, src_offset = 0;
|
||||
for (int i = 0; i < buf_ofst_info->num_units; i++) {
|
||||
si_copy_buffer(sctx, &new_buf->b.b, &old_buf->b.b,
|
||||
dst_offset, src_offset, buf_ofst_info->old_offset);
|
||||
dst_offset += buf_ofst_info->new_offset;
|
||||
src_offset += buf_ofst_info->old_offset;
|
||||
}
|
||||
} else {
|
||||
bytes = MIN2(new_buf->b.b.width0, old_buf->b.b.width0);
|
||||
si_copy_buffer(sctx, &new_buf->b.b, &old_buf->b.b, 0, 0, bytes);
|
||||
}
|
||||
context->flush(context, NULL, 0);
|
||||
}
|
||||
|
||||
si_resource_reference(&old_buf, NULL);
|
||||
*buf = new_buf;
|
||||
return true;
|
||||
|
||||
error:
|
||||
if (src)
|
||||
ws->buffer_unmap(ws, old_buf->buf);
|
||||
si_resource_reference(&new_buf, NULL);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef RADEON_VIDEO_H
|
||||
#define RADEON_VIDEO_H
|
||||
|
||||
#include "winsys/radeon_winsys.h"
|
||||
#include "vl/vl_video_buffer.h"
|
||||
#include "si_pipe.h"
|
||||
#include "util/log.h"
|
||||
|
||||
#undef MESA_LOG_TAG
|
||||
#define MESA_LOG_TAG "radeonsi"
|
||||
|
||||
#define RVID_ERR(fmt, args...) \
|
||||
mesa_loge("%s:%d %s UVD - " fmt, __FILE__, __LINE__, __func__, ##args)
|
||||
|
||||
#define UVD_FW_1_66_16 ((1 << 24) | (66 << 16) | (16 << 8))
|
||||
|
||||
/* video buffer offset info representation */
|
||||
struct rvid_buf_offset_info {
|
||||
unsigned num_units;
|
||||
unsigned old_offset;
|
||||
unsigned new_offset;
|
||||
};
|
||||
|
||||
/* generate an stream handle */
|
||||
unsigned si_vid_alloc_stream_handle(void);
|
||||
|
||||
/* reallocate a buffer, preserving its content */
|
||||
bool si_vid_resize_buffer(struct pipe_context *context,
|
||||
struct si_resource **buf, unsigned new_size,
|
||||
struct rvid_buf_offset_info *buf_ofst_info);
|
||||
|
||||
#endif // RADEON_VIDEO_H
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
#include "ac_shader_util.h"
|
||||
#include "radeon_uvd_enc.h"
|
||||
#include "radeon_vce.h"
|
||||
#include "radeon_video.h"
|
||||
#include "si_video.h"
|
||||
#include "si_pipe.h"
|
||||
#include "util/u_cpu_detect.h"
|
||||
#include "util/u_screen.h"
|
||||
|
|
|
|||
|
|
@ -11,11 +11,90 @@
|
|||
#include "radeon_uvd_enc.h"
|
||||
#include "radeon_vce.h"
|
||||
#include "radeon_vcn_enc.h"
|
||||
#include "radeon_video.h"
|
||||
#include "si_pipe.h"
|
||||
#include "si_vpe.h"
|
||||
#include "util/u_video.h"
|
||||
#include "vl/vl_video_buffer.h"
|
||||
#include "si_video_dec.h"
|
||||
#include "ac_uvd_dec.h"
|
||||
|
||||
unsigned si_vid_alloc_stream_handle()
|
||||
{
|
||||
static struct ac_uvd_stream_handle stream_handle;
|
||||
if (!stream_handle.base)
|
||||
ac_uvd_init_stream_handle(&stream_handle);
|
||||
return ac_uvd_alloc_stream_handle(&stream_handle);
|
||||
}
|
||||
|
||||
bool si_vid_resize_buffer(struct pipe_context *context,
|
||||
struct si_resource **buf, unsigned new_size,
|
||||
struct rvid_buf_offset_info *buf_ofst_info)
|
||||
{
|
||||
struct si_context *sctx = (struct si_context *)context;
|
||||
struct si_screen *sscreen = (struct si_screen *)context->screen;
|
||||
struct radeon_winsys *ws = sscreen->ws;
|
||||
struct si_resource *new_buf = *buf;
|
||||
unsigned bytes = MIN2(new_buf->buf->size, new_size);
|
||||
struct si_resource *old_buf = new_buf;
|
||||
void *src = NULL, *dst = NULL;
|
||||
|
||||
new_buf = si_resource(pipe_buffer_create(context->screen, old_buf->b.b.bind, old_buf->b.b.usage, new_size));
|
||||
if (!new_buf)
|
||||
goto error;
|
||||
|
||||
if (old_buf->b.b.usage == PIPE_USAGE_STAGING) {
|
||||
src = ws->buffer_map(ws, old_buf->buf, NULL, PIPE_MAP_READ | RADEON_MAP_TEMPORARY);
|
||||
if (!src)
|
||||
goto error;
|
||||
|
||||
dst = ws->buffer_map(ws, new_buf->buf, NULL, PIPE_MAP_WRITE | RADEON_MAP_TEMPORARY);
|
||||
if (!dst)
|
||||
goto error;
|
||||
|
||||
if (buf_ofst_info) {
|
||||
memset(dst, 0, new_size);
|
||||
for(int i =0; i < buf_ofst_info->num_units; i++) {
|
||||
memcpy(dst, src, buf_ofst_info->old_offset);
|
||||
dst += buf_ofst_info->new_offset;
|
||||
src += buf_ofst_info->old_offset;
|
||||
}
|
||||
} else {
|
||||
memcpy(dst, src, bytes);
|
||||
if (new_size > bytes) {
|
||||
new_size -= bytes;
|
||||
dst += bytes;
|
||||
memset(dst, 0, new_size);
|
||||
}
|
||||
}
|
||||
ws->buffer_unmap(ws, new_buf->buf);
|
||||
ws->buffer_unmap(ws, old_buf->buf);
|
||||
} else {
|
||||
si_barrier_before_simple_buffer_op(sctx, 0, &new_buf->b.b, &old_buf->b.b);
|
||||
if (buf_ofst_info) {
|
||||
uint64_t dst_offset = 0, src_offset = 0;
|
||||
for (int i = 0; i < buf_ofst_info->num_units; i++) {
|
||||
si_copy_buffer(sctx, &new_buf->b.b, &old_buf->b.b,
|
||||
dst_offset, src_offset, buf_ofst_info->old_offset);
|
||||
dst_offset += buf_ofst_info->new_offset;
|
||||
src_offset += buf_ofst_info->old_offset;
|
||||
}
|
||||
} else {
|
||||
bytes = MIN2(new_buf->b.b.width0, old_buf->b.b.width0);
|
||||
si_copy_buffer(sctx, &new_buf->b.b, &old_buf->b.b, 0, 0, bytes);
|
||||
}
|
||||
context->flush(context, NULL, 0);
|
||||
}
|
||||
|
||||
si_resource_reference(&old_buf, NULL);
|
||||
*buf = new_buf;
|
||||
return true;
|
||||
|
||||
error:
|
||||
if (src)
|
||||
ws->buffer_unmap(ws, old_buf->buf);
|
||||
si_resource_reference(&new_buf, NULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a video buffer with an UVD compatible memory layout
|
||||
|
|
|
|||
|
|
@ -7,7 +7,28 @@
|
|||
#ifndef SI_VIDEO_H
|
||||
#define SI_VIDEO_H
|
||||
|
||||
#include "pipe/p_context.h"
|
||||
#include "si_pipe.h"
|
||||
#include "pipe/p_video_codec.h"
|
||||
|
||||
#define RVID_ERR(fmt, args...) \
|
||||
mesa_loge("%s:%d %s UVD - " fmt, __FILE__, __LINE__, __func__, ##args)
|
||||
|
||||
#define UVD_FW_1_66_16 ((1 << 24) | (66 << 16) | (16 << 8))
|
||||
|
||||
/* video buffer offset info representation */
|
||||
struct rvid_buf_offset_info {
|
||||
unsigned num_units;
|
||||
unsigned old_offset;
|
||||
unsigned new_offset;
|
||||
};
|
||||
|
||||
/* generate a stream handle */
|
||||
unsigned si_vid_alloc_stream_handle(void);
|
||||
|
||||
/* reallocate a buffer, preserving its content */
|
||||
bool si_vid_resize_buffer(struct pipe_context *context,
|
||||
struct si_resource **buf, unsigned new_size,
|
||||
struct rvid_buf_offset_info *buf_ofst_info);
|
||||
|
||||
struct pipe_video_buffer *si_video_buffer_create(struct pipe_context *pipe,
|
||||
const struct pipe_video_buffer *tmpl);
|
||||
|
|
|
|||
|
|
@ -6,9 +6,10 @@
|
|||
|
||||
#include "si_video_dec.h"
|
||||
#include "si_pipe.h"
|
||||
#include "radeon_video.h"
|
||||
#include "si_video.h"
|
||||
#include "util/u_video.h"
|
||||
#include "util/vl_zscan_data.h"
|
||||
#include "vl/vl_video_buffer.h"
|
||||
#include "ac_debug.h"
|
||||
|
||||
#define ERROR(fmt, args...) \
|
||||
|
|
|
|||
|
|
@ -30,8 +30,9 @@
|
|||
|
||||
#include "pipe/p_screen.h"
|
||||
#include "pipe/p_video_codec.h"
|
||||
#include "vl/vl_video_buffer.h"
|
||||
#include "vpelib/inc/vpelib.h"
|
||||
#include "radeon_video.h"
|
||||
#include "si_video.h"
|
||||
|
||||
/* The buffer size of cmd_buf and emb_buf in bytes
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue