Skip to content

Commit 0e1ef96

Browse files
committed
GPU (Linux): detect shared vram usage of AMD GPU
1 parent c377872 commit 0e1ef96

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/detection/gpu/gpu_drm.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,20 @@ const char* ffDrmDetectRadeon(const FFGPUOptions* options, FFGPUResult* gpu, con
5050
if (ioctl(fd, DRM_IOCTL_RADEON_GEM_INFO, &gemInfo) >= 0 && gemInfo.vram_visible > 0)
5151
{
5252
gpu->dedicated.total = gemInfo.vram_visible;
53+
gpu->shared.total = gemInfo.gart_size;
54+
5355
uint64_t memSize;
5456
if (ioctl(fd, DRM_IOCTL_RADEON_INFO, &(struct drm_radeon_info) {
5557
.request = RADEON_INFO_VRAM_USAGE, // uint64_t
5658
.value = (uintptr_t) &memSize,
5759
}) >= 0)
5860
gpu->dedicated.used = memSize;
61+
62+
if (ioctl(fd, DRM_IOCTL_RADEON_INFO, &(struct drm_radeon_info) {
63+
.request = RADEON_INFO_GTT_USAGE, // uint64_t
64+
.value = (uintptr_t) &memSize,
65+
}) >= 0)
66+
gpu->shared.used = memSize;
5967
}
6068
}
6169

@@ -126,16 +134,13 @@ const char* ffDrmDetectAmdgpu(const FFGPUOptions* options, FFGPUResult* gpu, con
126134
struct amdgpu_heap_info heapInfo;
127135
if (ffamdgpu_query_heap_info(handle, AMDGPU_GEM_DOMAIN_VRAM, 0, &heapInfo) >= 0)
128136
{
129-
if (gpu->type == FF_GPU_TYPE_DISCRETE)
130-
{
131-
gpu->dedicated.total = heapInfo.heap_size;
132-
gpu->dedicated.used = heapInfo.heap_usage;
133-
}
134-
else
135-
{
136-
gpu->shared.total = heapInfo.heap_size;
137-
gpu->shared.used = heapInfo.heap_usage;
138-
}
137+
gpu->dedicated.total = heapInfo.heap_size;
138+
gpu->dedicated.used = heapInfo.heap_usage;
139+
}
140+
if (ffamdgpu_query_heap_info(handle, AMDGPU_GEM_DOMAIN_GTT, 0, &heapInfo) >= 0)
141+
{
142+
gpu->shared.total = heapInfo.heap_size;
143+
gpu->shared.used = heapInfo.heap_usage;
139144
}
140145
}
141146

0 commit comments

Comments
 (0)