mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 22:10:10 +01:00
intel/common: Add intel_gem_read_correlate_cpu_gpu_timestamp()
This function will make use of Xe DRM_XE_DEVICE_QUERY_ENGINE_CYCLES by returning correlate CPU ang GPU timestamp to be used by Intel drives. This correlate timestamps gives us more accuracy. Signed-off-by: José Roberto de Souza <jose.souza@intel.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24591>
This commit is contained in:
parent
b6dbbd3ff7
commit
ae0df368a8
4 changed files with 95 additions and 2 deletions
|
|
@ -116,6 +116,32 @@ intel_gem_read_render_timestamp(int fd,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
intel_gem_read_correlate_cpu_gpu_timestamp(int fd,
|
||||||
|
enum intel_kmd_type kmd_type,
|
||||||
|
enum intel_engine_class engine_class,
|
||||||
|
uint16_t engine_instance,
|
||||||
|
clockid_t cpu_clock_id,
|
||||||
|
uint64_t *cpu_timestamp,
|
||||||
|
uint64_t *gpu_timestamp,
|
||||||
|
uint64_t *cpu_delta)
|
||||||
|
{
|
||||||
|
switch (kmd_type) {
|
||||||
|
case INTEL_KMD_TYPE_I915:
|
||||||
|
return false;
|
||||||
|
case INTEL_KMD_TYPE_XE:
|
||||||
|
return xe_gem_read_correlate_cpu_gpu_timestamp(fd, engine_class,
|
||||||
|
engine_instance,
|
||||||
|
cpu_clock_id,
|
||||||
|
cpu_timestamp,
|
||||||
|
gpu_timestamp,
|
||||||
|
cpu_delta);
|
||||||
|
default:
|
||||||
|
unreachable("Missing");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
intel_gem_create_context_ext(int fd, enum intel_gem_create_context_flags flags,
|
intel_gem_create_context_ext(int fd, enum intel_gem_create_context_flags flags,
|
||||||
uint32_t *ctx_id)
|
uint32_t *ctx_id)
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <time.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
@ -88,6 +89,15 @@ bool intel_gem_supports_syncobj_wait(int fd);
|
||||||
bool
|
bool
|
||||||
intel_gem_read_render_timestamp(int fd, enum intel_kmd_type kmd_type,
|
intel_gem_read_render_timestamp(int fd, enum intel_kmd_type kmd_type,
|
||||||
uint64_t *value);
|
uint64_t *value);
|
||||||
|
bool
|
||||||
|
intel_gem_read_correlate_cpu_gpu_timestamp(int fd,
|
||||||
|
enum intel_kmd_type kmd_type,
|
||||||
|
enum intel_engine_class engine_class,
|
||||||
|
uint16_t engine_instance,
|
||||||
|
clockid_t cpu_clock_id,
|
||||||
|
uint64_t *cpu_timestamp,
|
||||||
|
uint64_t *gpu_timestamp,
|
||||||
|
uint64_t *cpu_delta);
|
||||||
bool intel_gem_can_render_on_fd(int fd, enum intel_kmd_type kmd_type);
|
bool intel_gem_can_render_on_fd(int fd, enum intel_kmd_type kmd_type);
|
||||||
|
|
||||||
/* Functions only used by i915 */
|
/* Functions only used by i915 */
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,11 @@
|
||||||
*/
|
*/
|
||||||
#include "xe/intel_gem.h"
|
#include "xe/intel_gem.h"
|
||||||
|
|
||||||
#include "common/intel_gem.h"
|
|
||||||
|
|
||||||
#include "drm-uapi/xe_drm.h"
|
#include "drm-uapi/xe_drm.h"
|
||||||
|
|
||||||
|
#include "common/intel_gem.h"
|
||||||
|
#include "common/xe/intel_engine.h"
|
||||||
|
|
||||||
bool
|
bool
|
||||||
xe_gem_read_render_timestamp(int fd, uint64_t *value)
|
xe_gem_read_render_timestamp(int fd, uint64_t *value)
|
||||||
{
|
{
|
||||||
|
|
@ -41,3 +42,48 @@ xe_gem_can_render_on_fd(int fd)
|
||||||
};
|
};
|
||||||
return intel_ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query) == 0;
|
return intel_ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
xe_gem_read_correlate_cpu_gpu_timestamp(int fd,
|
||||||
|
enum intel_engine_class engine_class,
|
||||||
|
uint16_t engine_instance,
|
||||||
|
clockid_t cpu_clock_id,
|
||||||
|
uint64_t *cpu_timestamp,
|
||||||
|
uint64_t *gpu_timestamp,
|
||||||
|
uint64_t *cpu_delta)
|
||||||
|
{
|
||||||
|
struct drm_xe_query_engine_cycles engine_cycles = {};
|
||||||
|
struct drm_xe_device_query query = {
|
||||||
|
.query = DRM_XE_DEVICE_QUERY_ENGINE_CYCLES,
|
||||||
|
.size = sizeof(engine_cycles),
|
||||||
|
.data = (uintptr_t)&engine_cycles,
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (cpu_clock_id) {
|
||||||
|
case CLOCK_MONOTONIC:
|
||||||
|
#ifdef CLOCK_MONOTONIC_RAW
|
||||||
|
case CLOCK_MONOTONIC_RAW:
|
||||||
|
#endif
|
||||||
|
case CLOCK_REALTIME:
|
||||||
|
case CLOCK_BOOTTIME:
|
||||||
|
case CLOCK_TAI:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
engine_cycles.eci.engine_class = intel_engine_class_to_xe(engine_class);
|
||||||
|
engine_cycles.eci.engine_instance = engine_instance;
|
||||||
|
engine_cycles.eci.gt_id = 0;
|
||||||
|
engine_cycles.clockid = cpu_clock_id;
|
||||||
|
|
||||||
|
if (intel_ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
*cpu_timestamp = engine_cycles.cpu_timestamp;
|
||||||
|
*gpu_timestamp = engine_cycles.engine_cycles;
|
||||||
|
if (cpu_delta)
|
||||||
|
*cpu_delta = engine_cycles.cpu_delta;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,17 @@
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include "common/intel_engine.h"
|
||||||
|
|
||||||
bool xe_gem_read_render_timestamp(int fd, uint64_t *value);
|
bool xe_gem_read_render_timestamp(int fd, uint64_t *value);
|
||||||
|
bool
|
||||||
|
xe_gem_read_correlate_cpu_gpu_timestamp(int fd,
|
||||||
|
enum intel_engine_class engine_class,
|
||||||
|
uint16_t engine_instance,
|
||||||
|
clockid_t cpu_clock_id,
|
||||||
|
uint64_t *cpu_timestamp,
|
||||||
|
uint64_t *gpu_timestamp,
|
||||||
|
uint64_t *cpu_delta);
|
||||||
bool xe_gem_can_render_on_fd(int fd);
|
bool xe_gem_can_render_on_fd(int fd);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue