kk: add mtl_device_get_gpu_timestamp bridge

Reviewed-by: Aitor Camacho <aitor@lunarg.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38965>
This commit is contained in:
Yiwei Zhang 2025-12-15 23:35:56 -08:00 committed by Marge Bot
parent 819213dc29
commit 3a73a7ba29
3 changed files with 25 additions and 1 deletions

View file

@ -29,6 +29,9 @@ uint32_t mtl_device_get_peer_index(mtl_device *dev);
uint64_t mtl_device_get_registry_id(mtl_device *dev);
struct mtl_size mtl_device_max_threads_per_threadgroup(mtl_device *dev);
/* Timestamp query */
uint64_t mtl_device_get_gpu_timestamp(mtl_device *dev);
/* Resource queries */
void mtl_heap_buffer_size_and_align_with_length(mtl_device *device,
uint64_t *size_B,
@ -37,4 +40,4 @@ void
mtl_heap_texture_size_and_align_with_descriptor(mtl_device *device,
struct kk_image_layout *layout);
#endif /* MTL_DEVICE_H */
#endif /* MTL_DEVICE_H */

View file

@ -129,6 +129,20 @@ mtl_device_max_threads_per_threadgroup(mtl_device *dev)
}
}
/* Timestamp query */
uint64_t
mtl_device_get_gpu_timestamp(mtl_device *dev)
{
@autoreleasepool {
id<MTLDevice> device = (id<MTLDevice>)dev;
MTLTimestamp cpu_ts, gpu_ts;
[device sampleTimestamps:&cpu_ts gpuTimestamp:&gpu_ts];
return (uint64_t)gpu_ts;
}
}
/* Resource queries */
/* TODO_KOSMICKRISP Return a struct */
void

View file

@ -59,6 +59,13 @@ mtl_device_max_threads_per_threadgroup(mtl_device *dev)
return (struct mtl_size){};
}
/* Timestamp query */
uint64_t
mtl_device_get_gpu_timestamp(mtl_device *dev)
{
return 0u;
}
/* Resource queries */
void
mtl_heap_buffer_size_and_align_with_length(mtl_device *device, uint64_t *size_B,