Skip to content

Commit

Permalink
Merge pull request #353 from Steve-Tech/amd-enc
Browse files Browse the repository at this point in the history
Fix shared encode/decode not being displayed on AMD
  • Loading branch information
Syllo authored Jan 19, 2025
2 parents c79a9c7 + cff83fa commit 3e8c6ae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/nvtop/interface_internal_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ struct device_window {
WINDOW *mem_util_no_enc_and_dec;
WINDOW *encode_util;
WINDOW *decode_util;
WINDOW *encdec_util;
WINDOW *fan_speed;
WINDOW *temperature;
WINDOW *power_info;
Expand Down
7 changes: 7 additions & 0 deletions src/extract_gpuinfo_amdgpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ static const char drm_amdgpu_enc[] = "drm-engine-enc";

static bool parse_drm_fdinfo_amd(struct gpu_info *info, FILE *fdinfo_file, struct gpu_process *process_info) {
struct gpu_info_amdgpu *gpu_info = container_of(info, struct gpu_info_amdgpu, base);
struct gpuinfo_static_info *static_info = &gpu_info->base.static_info;
static char *line = NULL;
static size_t line_buf_size = 0;
ssize_t count = 0;
Expand Down Expand Up @@ -966,6 +967,12 @@ static bool parse_drm_fdinfo_amd(struct gpu_info *info, FILE *fdinfo_file, struc
cache_entry->client_id.pdev = gpu_info->base.pdev;
}

// The UI only shows the decode usage when `encode_decode_shared` is true
// but amdgpu should only use the encode usage field when it is shared.
// Lets add both together for good measure.
if (static_info->encode_decode_shared)
SET_GPUINFO_PROCESS(process_info, decode_usage, process_info->decode_usage + process_info->encode_usage);

#ifndef NDEBUG
// We should only process one fdinfo entry per client id per update
struct amdgpu_process_info_cache *cache_entry_check;
Expand Down
8 changes: 7 additions & 1 deletion src/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ static void alloc_device_window(unsigned int start_row, unsigned int start_col,
dwin->decode_util = newwin(1, size_decode, start_row + 2, start_col + spacer * 3 + size_gpu + size_mem + size_encode);
if (dwin->decode_util == NULL)
goto alloc_error;
dwin->encdec_util = newwin(1, size_encode * 2, start_row + 2, start_col + spacer * 2 + size_gpu + size_mem);
if (dwin->encdec_util == NULL)
goto alloc_error;
// For auto-hide encode / decode window
dwin->gpu_util_no_enc_or_dec = newwin(1, size_gpu + size_encode / 2 + 1, start_row + 2, start_col);
if (dwin->gpu_util_no_enc_or_dec == NULL)
Expand Down Expand Up @@ -190,6 +193,7 @@ static void free_device_windows(struct device_window *dwin) {
delwin(dwin->mem_util_no_enc_and_dec);
delwin(dwin->encode_util);
delwin(dwin->decode_util);
delwin(dwin->encdec_util);
delwin(dwin->gpu_clock_info);
delwin(dwin->mem_clock_info);
delwin(dwin->power_info);
Expand Down Expand Up @@ -646,9 +650,11 @@ static void draw_devices(struct list_head *devices, struct nvtop_interface *inte
WINDOW *mem_util_win;
WINDOW *encode_win = dev->encode_util;
WINDOW *decode_win = dev->decode_util;
if (display_encode && display_decode) {
if ((display_encode && display_decode) || (display_decode && device->static_info.encode_decode_shared)) {
gpu_util_win = dev->gpu_util_enc_dec;
mem_util_win = dev->mem_util_enc_dec;
if (device->static_info.encode_decode_shared)
decode_win = dev->encdec_util;
} else {
if (display_encode || display_decode) {
// If encode only, place at decode location
Expand Down

0 comments on commit 3e8c6ae

Please sign in to comment.